| cor.by.group | R Documentation |
Computes the correlation between x and y separately within each
of several groups defined by all of the combinations of the factor variables
contained within by. For example, correlate high school GPA with
college GPA separately within each of several universities, or correlate
working memory score with response time separately in each cell of a 2 x 2
factorial experiment.
cor.by.group(x, y, INDEX, ...)
x |
one of the numeric vectors to be correlated. |
y |
the other numeric vector to be correlated. |
INDEX |
list of one or more grouping variables, typically factors, each
of the same length as |
... |
arguments to |
cor for correlations without division into groups.
data(grouseticks, package='lme4') cor.by.group(grouseticks$HEIGHT, grouseticks$TICKS, INDEX=grouseticks$YEAR) # Correlation of HEIGHTS and TICKS separately for each YEAR data(Arabidopsis, package='lme4') cor.by.group(Arabidopsis$nutrient, Arabidopsis$total.fruits, INDEX=list(Arabidopsis$reg, Arabidopsis$status)) # Correlation of nutrient and total.fruits for each combination of # reg x status
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.