[R] Odp: create frequency table

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Tue, 27 May 2008 09:02:48 +0200

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.



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. Received on Tue 27 May 2008 - 07:12:14 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 Tue 27 May 2008 - 08:30:39 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