You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just tried to assign new document names to a dfm()/tokens() object. The documentation says that docnames() "gets or sets document names of a corpus, tokens, or dfm object".
However, it seems that setting docnames currently does not work for dfm()/tokens() objects. So either we fix this or change the documentation stating that setting docnames (currently) is only possible for corpus() objects.
docnames(data_corpus_inaugural) <- paste("Speech", 1:ndoc(data_corpus_inaugural), sep="")
head(docnames(data_corpus_inaugural))
# [1] "Speech1" "Speech2" "Speech3" "Speech4" "Speech5" "Speech6"dfm_inaugural<- dfm(data_corpus_inaugural)
docnames(dfm_inaugural) <- paste("Speech", 1:ndoc(dfm_inaugural), sep="")
# Error in UseMethod("docnames<-") : # no applicable method for 'docnames<-' applied to an object of class "c('dfmSparse', 'dfm', # 'dgCMatrix', 'CsparseMatrix', 'dsparseMatrix', 'generalMatrix', 'dCsparseMatrix', 'dMatrix', # 'sparseMatrix', 'compMatrix', 'Matrix', 'xMatrix', 'mMatrix', 'Mnumeric', 'replValueSp')"tokens_inaugural<- tokens(data_corpus_inaugural)
docnames(tokens_inaugural) <- paste("Speech", 1:ndoc(tokens_inaugural), sep="")
# Error in UseMethod("docnames<-") : # no applicable method for 'docnames<-' applied to an object of class "c('tokens', 'tokenizedTexts')"
The text was updated successfully, but these errors were encountered:
True - we decided not to allow people to set docnames on "downstream" objects such as tokens or dfm objects. The idea is the the docnames would be baked in at the time of construction.
I agree we could produce a better output message than the standard "no applicable method" error.
But we could also consider allowing it. @koheiw what do you think?
I think it is OK to allow assignment of docnames. I sometimes use names() to change docnames of tokens. In the long term, docnames should be stored as a system-level docvar, not as names of list or row names of data.frame.
Just tried to assign new document names to a
dfm()
/tokens()
object. The documentation says thatdocnames()
"gets or sets document names of a corpus, tokens, or dfm object".However, it seems that setting docnames currently does not work for
dfm()
/tokens()
objects. So either we fix this or change the documentation stating that setting docnames (currently) is only possible forcorpus()
objects.The text was updated successfully, but these errors were encountered: