[R] lapply to multivariate function?

Rui Barradas ruipbarradas at sapo.pt
Sun Sep 1 16:31:05 CEST 2013


Hello,

Maybe you need apply, not lapply. It seems you want to apply() a 
function to the first dimension of your data.frame, something like

apply(dat, 1, fun)  #apply by rows


Hope this helps,

Rui Barradas

Em 01-09-2013 15:00, Ignacio Martinez escreveu:
> I have a Data Frame that contains, between other things, the following
> fields: userX, Time1, Time2, Time3. The number of observations is 2000.
>
> I have a function that has as inputs userX, Time1, Time2, Time3 and return
> a data frame with 1 observation and 19 variables.
>
> I want to apply that function to all the observations of the first data
> frame to make a new data frame with 2000 observations and 19 variables.
>
> I thought about using lapply, but if I understand correctly, it only takes
> one variable.
>
> Can somebody point me in the right direction?
>
> Thanks!
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list