[R] create a correct list from Document Term Matrix
Elahe chalabi
chalabi.elahe at yahoo.de
Sat May 6 16:47:08 CEST 2017
Hi all,
I have a text classification task which is classification of a Control group and Alzheimer group texts. I have generated DocumentTermMatrix for both groups and then created a list with one extra element showing the group name if it's Alzheimer or control group, for example for the Alzheimer group:
frequenciesAlzheimer=DocumentTermMatrix(corpus)
freqlistAlz=list(type="alzheimer",frequenciesAlzheimer)
List of 2
$ type: chr "alzheimer"
$ :List of 6 *
..$ i : int [1:8678] 1 1 1 1 1 1 1 1 1 1 ...
..$ j : int [1:8678] 1 2 3 4 5 6 7 8 9 10 ...
..$ v : num [1:8678] 1 1 1 1 1 2 1 1 2 1 ...
..$ nrow : int 255
..$ ncol : int 1091
..$ dimnames:List of 2
.. ..$ Docs : chr [1:255] "1" "2" "3" "4" ...
.. ..$ Terms: chr [1:1091] "alright" "bad" "boy" "cookie" ...
..- attr(*, "class")= chr [1:2] "DocumentTermMatrix" "simple_triplet_matrix"
..- attr(*, "weighting")= chr [1:2] "term frequency" "tf"
and I have the same list for control group,now my question is why I don't get the name of my DTM as the second element of my list? in the line marked by *
I need to have
$frequenciesAlzheimer : List of 6
but there's no name, does anyone know how should I solve this?
Thanks for any help!
Elahe
More information about the R-help
mailing list