Re: [R] R-help with apply and ccf

From: ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be>
Date: Tue, 22 May 2007 18:00:45 +0200


You could combine them with cbind, and then split the rows again inside the function you're calling with apply.

Mat <- cbind(mat1, mat2)
apply(Mat, 1, function(x){

	row.mat1 <- x[seq_len(length(x)/2)]
	row.mat2 <- x[length(x)/2 + seq_len(length(x)/2)]
	cor(row.mat1, row.mat2)

})

Cheers,

Thierry




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
Thierry.Onkelinx_at_inbo.be
www.inbo.be

Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney  

> -----Oorspronkelijk bericht-----
> Van: r-help-bounces_at_stat.math.ethz.ch
> [mailto:r-help-bounces_at_stat.math.ethz.ch] Namens Michael Andric
> Verzonden: dinsdag 22 mei 2007 17:35
> Aan: r-help_at_stat.math.ethz.ch
> Onderwerp: [R] R-help with apply and ccf
>
> Dear R gurus,
>
> I would like to use the ccf function on two matrices that are
> each 196000 x 12. Ideally, I want to be able to go row by
> row for the two matrices using apply for the ccf function and
> get one 196000 X 1 array output. The apply function though
> wants only one array, no? Basically, is there a way to use
> apply when there are two arrays in order to do something like
> correlation on a row by row basis?
> Thanks for your help
>
> Michael
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.
>



R-help_at_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 Tue 22 May 2007 - 16:06:20 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 Tue 22 May 2007 - 16:31:34 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.