[R] table() result issue

2011-03-16 Thread Frédérique Kuiper
Dear reader, I have the following problem: I have some string with numbers like k. I want to have a table like the function table() gives. However I am not able to call the first row, the 1, 2, 3, 5, 6 or 9. I tried to do that by a data.frame, but that doesn't seem to work either. The

Re: [R] table() result issue

2011-03-16 Thread Dennis Murphy
k-c(1,1,1,1,1,3,5,6,2,1,3,9,2,3,1,1,1) table(k) k 1 2 3 5 6 9 9 2 3 1 1 1 names(table(k)) [1] 1 2 3 5 6 9 as.numeric(names(table(k))) [1] 1 2 3 5 6 9 x - table(k) as.numeric(names(table(k)))[4] [1] 5 You can always save the (numeric version of the) names as an object, too. Does that help?