Re: [R] sequencial frequency table

From: Marc Schwartz <marc_schwartz_at_comcast.net>
Date: Tue 30 Jan 2007 - 14:48:44 GMT

On Tue, 2007-01-30 at 10:03 -0300, Mauricio Cardeal wrote:
> Hi.
>
> I have the data frame xyz below and Id like to perform a sequencial
> frequency table using some unique function instead of making 3 different
> one-by-one table (table x, table y and table z). But Icant figure out
> the correct way.
>
> x <- c(2,3,2,4)
> y <- c(3,1,1,1)
> z <- c(4,2,1,4)
> xyz <- as.data.frame(cbind(x,y,z))
>
> freq <- function(x){
> table(x)
> }
>
> freq(xyz)
>
> Thank you,
> Mauricio

Is that what you want?

> lapply(xyz, table)

$x

2 3 4
2 1 1

$y

1 3
3 1

$z

1 2 4
1 1 2

See ?lapply if so.

HTH, Marc Schwartz



R-help@stat.math.ethz.ch 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 Wed Jan 31 02:05:01 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 30 Jan 2007 - 15:30:25 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.