I am quite new to R, sorry if my question will trivial. I try to work with clouds of words. The function comparison.cloud is supposed to accept a Term-Document Matrix with words' frequencies matrix built like that:
head(term.matrix,1)
Docs
Terms SOTU 2010 SOTU 2011
’ll 3 8
colnames(term.matrix)
[1] "SOTU 2010" "SOTU 2011"
I try to build such a matrix myself but I am confused why "Terms" is not considered as a column name and why "Docs" is above the two column names "SOTU 2010" and "SOTU 2011"...
Can someone explain me that please?
The
dimnamesattribute of a matrix, if notNULL, is a list of the formlist(rownames, colnames)storing the row names and column names of the matrix.Sometimes, it is convenient for the list itself to have names. These names act somewhat like axis titles:
lois printed on the same line as the column names, but it is really the title of the first dimension. Similarly,UPis the title of the second dimension.TermDocumentMatrixandDocumentTermMatrixobjects are not true R matrices. They store nonzero elements in triplet format for efficiency, as well as some metadata. However, like true R matrices, they can have adimnamesattribute. Since the rows and columns represent terms and documents (or vice versa), packagetmassigns namesTermsandDocsto thedimnames.Taking an example from
vignette("tm"):Hence: