Re: [R] lapply with functions with changing parameters

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Tue, 01 Jun 2010 18:01:55 -0300

Try this:

 lapply(mydf[-6], ccf, y = mydf[6])

On Tue, Jun 1, 2010 at 5:50 PM, Bunny, lautloscrew.com < bunny_at_lautloscrew.com> wrote:

> Dear all,
>
> I am trying to avoid a for loop here and wonder if the following is
> possible:
>
> I have a data.frame with 6 columns and i want to get a cross-correlogram
> (by using ccf) . Obivously ccf only accepts two columns at once and then
> returms a list.
> In fact, with a for loop i´d do the following
>
>
> for (i in 1:6) {
>
> x[[i]]=ccf(mydf[,i],mydf[,6])
>
>
> }
>
> Is there any chance to the same with lapply? e.g. lapply(mydf,"ccf", .... )
> with ... respresenting the changing arguments for ccf functions (note only
> the first argument does actually change)
>
> thx for any suggestions in advance
>
> best
>
> matt
> ______________________________________________
> 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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[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.

Received on Tue 01 Jun 2010 - 21:04:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 09: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.

list of date sections of archive