[R] correlation by factor

Marlin Keith Cox m@r||nkcox @end|ng |rom gm@||@com
Wed Jul 28 02:29:33 CEST 2021


I am having problems making a correlation/association between two variables
by a factor.

In the case below, I need to know the correlation between R and Day at each
frequency (a1-a5). Each frequency would have a corresponding correlation
between R and day.

I have found a lm function that is similar to what I need.
lm(R~Day*Freq), but this wont apply to the cor function.

Mind you, I have hundreds of these to with these same three columns, so if
there is an association package, I would be interested in those too.  I did
research it, but it quickly went over my head, so I thought I would
approach my problem this way.

Data is below.

Keith

R<-c(1,8,3,6,7,2,3,7,2,3,3,4,3,7,3)
Day<-c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3)
Freq<-(a1,a2,a3,a4,a5,a1,a2,a3,a4,a5,a1,a2,a3,a4,a5,)



M. Keith Cox, Ph.D.
Principal
MKConsulting
17415 Christine Ave.
Juneau, AK 99801
U.S. 907.957.4606

	[[alternative HTML version deleted]]



More information about the R-help mailing list