[R] Odp: create frequency table

Petr PIKAL petr.pikal at precheza.cz
Tue May 27 09:02:48 CEST 2008


Hi

r-help-bounces at r-project.org napsal dne 27.05.2008 03:58:43:

> 
> I haven't quite been able to grasp how to use "hist" to create frequency
> tables so I have decided it will be easier to make my own.
> 
> I have a list of numeric data, x, from 0 to 30:
> x <- sample(0:30, 100)

Not list but vector. Besides the above version gives you error. Use

x <- sample(0:30, 100, replace=T)

instead.

> 
> I've created an object containing the bins I would like frequency counts 
by:
> z <- as.matrix(seq(from=0, to=30, by=1))

Maybe it would be easier to use table function 

table(x)

> 
> I would now like to create a new column in z containing counts of all 
values
> in x less than or equal to [m,1], thereby allowing me to conduct further
> modifications.  My intuition tells me this is not that difficult but I 
lack

I am not sure what do you exactly want but maybe

table(x[x<20])

Regards
Petr

> the programming prowess.
> 
> Does anyone have a solution?
> 
> -- 
> View this message in context: 
http://www.nabble.com/create-frequency-table-
> tp17481748p17481748.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



More information about the R-help mailing list