[R] table() reading problem

From: fre <fre_stamlid_at_hotmail.com>
Date: Wed, 16 Mar 2011 02:20:10 -0700 (PDT)

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 levels keep bothering me.

This is an example of the code:

> table(k)

1 2 3 5 6 9
9 2 3 1 1 1
> x<-table(k)
> dim(x)

[1] 6
> x[1] #But i only want the one

> x<-data.frame(x)
> x[1,1] #You are not allowed to use this one for example 3*x[1,1] is

> impossible

[1] 1
Levels: 1 2 3 5 6 9

I hope anyone has an idea of using the table function without this inconvenience. I thought about writing a counter myself, but that seems complicated.
Because I have to examine very large examples later on, I don't want to slow the calculations down if possible.

Thanks for your help in advance.


View this message in context: http://r.789695.n4.nabble.com/table-reading-problem-tp3381174p3381174.html
Sent from the R help mailing list archive at Nabble.com.

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 16 Mar 2011 - 12:50:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Mar 2011 - 08:50:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive