[R] R-help with apply and ccf

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Tue May 22 18:00:45 CEST 2007

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)



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
tel. + 32 54/436 185
Thierry.Onkelinx op 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 op stat.math.ethz.ch 
> [mailto:r-help-bounces op stat.math.ethz.ch] Namens Michael Andric
> Verzonden: dinsdag 22 mei 2007 17:35
> Aan: r-help op 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 op 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.

More information about the R-help mailing list