One correction below, 

---snip---

> >
> > # example data frame
> > testDF<-data.frame(
> >     x=rnorm(12),
> >     y=rnorm(12),
> >     f1=gl(3,4),
> >     f2=gl(2,2,12))
> >
> 
> Try this using lapply, split, mapply?  Maybe it is in a nicer output
> object for you?
> 
> testFun2 <- function(x, y) {
>   X <- abs(x);
>   Y <- abs(y);
>   as.numeric(paste(round(X), round(Y), sep='.'))
> }
> 
> lapply(split(testDF, list(testDF$f1, testDF$f2)),
>        function(x) mapply(testFun2, x[1], x[2]))
> 

Or use "list indexing" in the mapply call to get a vector, in this case at 
least...

lapply(split(testDF, list(testDF$f1, testDF$f2)),
       function(x) mapply(testFun2, x[[1]], x[[2]]))

---snip---

______________________________________________
[email protected] 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.

Reply via email to