|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
create frequency tableI 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) I've created an object containing the bins I would like frequency counts by: z <- as.matrix(seq(from=0, to=30, by=1)) 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 the programming prowess. Does anyone have a solution? |
|
|
Odp: create frequency tableHi
r-help-bounces@... 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@... 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@... 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. |
|
|
Re: Odp: create frequency tableHi Petr
My mistake in omitting "replace=T" in the first part. Unfortunately I oversimplified my problem as I'm not actually dealing with whole numbers but numerous significant digits, therefore the table option will not assist me in this case. My bin size will vary to the order of 0.05-1. Perhaps try these instead: x <- rnorm(1:100) z<-seq(from=-2.5, to=3.5, by=0.5) Cheers, Tyler ______________________________________________ R-help@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. |
|
|
Re: Odp: create frequency tabler-help-bounces@... napsal dne 27.05.2008 09:31:16:
> > Hi Petr > > My mistake in omitting "replace=T" in the first part. > Unfortunately I oversimplified my problem as I'm not actually dealing with > whole numbers but numerous significant digits, therefore the table option > will not assist me in this case. My bin size will vary to the order of > 0.05-1. > > Perhaps try these instead: > x <- rnorm(1:100) > z<-seq(from=-2.5, to=3.5, by=0.5) OK, then you can use table with cut and maybe findInterval as mentioned in help page. e.g. table(cut(x,c(-Inf, z, +Inf))) Regards Petr > > Cheers, > Tyler > > ______________________________________________ > R-help@... 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. > > > > -- > View this message in context: http://www.nabble.com/create-frequency-table- > tp17481748p17484689.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@... 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@... 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. |
|
|
Re: Odp: create frequency tableThis definitely does the trick.
I knew there was an easier way!
|
| Free embeddable forum powered by Nabble | Forum Help |