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
> On May 6, 2017, at 7:47 AM, Elahe chalabi via R-help <r-help at r-project.org> wrote: > > 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?Why don't you just assign a name to that list? Either of these should succeed: names(freqlistAlz)[2] <- frequenciesAlzheimer freqlistAlz=list(type="alzheimer", frequenciesAlzheimer = frequenciesAlzheimer) -- David.> > Thanks for any help! > Elahe > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA
> On May 6, 2017, at 8:14 AM, David Winsemius <dwinsemius at comcast.net> wrote: > >> >> On May 6, 2017, at 7:47 AM, Elahe chalabi via R-help <r-help at r-project.org> wrote: >> >> 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? > > Why don't you just assign a name to that list? Either of these should succeed: > > > names(freqlistAlz)[2] <- frequenciesAlzheimerSigh. The dangers of untested code (due to no offered example.) My wetware interpreter now tells me that it probably should have been: names(freqlistAlz)[2] <- "frequenciesAlzheimer"> > freqlistAlz=list(type="alzheimer", > frequenciesAlzheimer = frequenciesAlzheimer) > > -- > David. > > >> >> Thanks for any help! >> Elahe >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > > David Winsemius > Alameda, CA, USA > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius Alameda, CA, USA