[R] sorting matrix output alphabetically
Bob Green
bgreen at dyson.brisnet.org.au
Sat Oct 18 11:59:05 CEST 2008
Hello,
I have been using the TM package to create a TermDocMatrix, which I
have saved as a matrix so that I can view word frequencies. Below is
a section of the code that I have used and an excerpt of the output:
What I wanted to be able to do is to view the output alphabetically -
rather than the results being sorted by frequency as below, that an
alphabetical list would be generated. This would be quite long as the
matrix is 176 x 2796, so I was hoping I could save the output in a
csv file, which could be manipulated either in R or EXCEL.
Any advice as to how I could do this is appreciated,
Bob
rec.matrix <- TermDocMatrix(recdata)
recdata.matrix <- findFreqTerms(rec.matrix, 5, Inf)
# creates a matrix
new.matrix <- as(Data(rec.matrix), "matrix")
tot <- colSums(new.matrix)
sort(tot)
unavail unwilling wheels
1 1 1
evans interviewed jill
1 1 1
referral achieved aids
More information about the R-help
mailing list