e-
> From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us]
> Sent: Sunday, December 07, 2014 3:14 PM
> To: John Posner
> Cc: 'Chel Hee Lee'; Morway, Eric; R mailing list
> Subject: Re: [R] Condensing data.frame
>
> dplyr version (good for large datasets):
>
> l
e there is no use of summarize(), I have not figured out how to use
the dplyr package in this context.
-John
-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chel Hee
Lee
Sent: Sunday, December 07, 2014 11:43 AM
To: Morway, Eric; R mailing list
Subject: Re
ize()
3. Because there is no use of summarize(), I have not figured out how to use
the dplyr package in this context.
-John
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chel Hee
> Lee
> Sent: Sunday, December 07, 2014 11:43 AM
&
> datBySite <- split(dat, dat$site)
> output <- lapply(datBySite, function(x){
+ x$idx <- seq_len(nrow(x))
+ x$grp <- ifelse(x$idx < 7, x$idx, 7)
+ rval <- tapply(x$countPercentage, x$grp, sum)
+ x$grp <- x$count <- x$countTotal <- NULL
+ x <- x[seq_len(7), ]
+ x$tax_name <- as.character(x$tax_nam
Using the dataset "dat" (found below), I'm seeking a way to condense down
the data.frame such that each "site" (i.e., "CID_1"..."CID_13") has a
maximum of 7 rows of post-processed data, where the first 6 have the
highest "countPercentage" and the 7th row is the sum of "countPercentage"
from all oth
5 matches
Mail list logo