> demo()
Use `demo(topic)' where choices for argument `topic' are:
topics
[1,] "graphics"
[2,] "image"
[3,] "lm.glm"
[4,] "glm.vr"
[5,] "nlm"
[6,] "recursion"
[7,] "scoping"
[8,] "is.things"
[9,] "dyn.load"
> demo("graphics")
demo(graphics)
---- ????????
Type to start :
>help(cor)
cor package:base R Documentation
Correlation and Covariance Matrices
Description:
Compute the correlation or covariance matrix of the columns of `x'
and the columns of `y'.
Usage:
cor(x, y=x, use="all.obs")
cov(x, y=x, use="all.obs")
Arguments:
x: a matrix or data frame.
y: a matrix or data frame.
use: a character string giving the method for handling missing
observations. This must be one of the stringss `"all.obs"',
`"complete.obs"' or `"pairwise.complete.obs"' (abbreviations
are acceptable).
Details:
If `use' is `"all.obs"', then the presence of missing observations
will cause the computation to fail. If `use' has the value
`"complete.obs"' then missing values are handled by casewise
deletion. Finally, if `use' has the value
`"pairwise.complete.obs"' then the correlation between each pair
of variables is computed using all complete pairs of observations
on those variables. This can result in covariance or correlation
matrices which are not positive semidefinite.
See Also:
`cov.wt' for weighted covariance computation.
Examples:
> qdata[ 1:2 ]
sei BodyWeight
2000-01 male 100.5
2000-02 female 105.4
2000-03 male 98.9
2000-04 male 116.2
2000-05 female 120.2
2000-06 female 127.4
2000-07 female 112.6
2000-08 female 109.8
2000-09 male 97.1
2000-10 male 102.3
> qdata[ qdata[1]=='female', ]
sei BodyWeight AgeAtFirstEggs NumberOfEggs
2000-02 female 105.4 40.5 31.3
2000-05 female 120.2 52.5 48.4
2000-06 female 127.4 49.6 43.2
2000-07 female 112.6 45.6 39.0
2000-08 female 109.8 43.5 37.1
> sortlist <- order(qdata$BodyWeight)
> sortlist
[1] 9 3 1 10 2 8 7 4 5 6
> qdata2 <- qdata[sortlist, ]
> qdata2
sei BodyWeight AgeAtFirstEggs NumberOfEggs
2000-09 male 97.1 NA NA
2000-03 male 98.9 NA NA
2000-01 male 100.5 NA NA
2000-10 male 102.3 NA NA
2000-02 female 105.4 40.5 31.3
2000-08 female 109.8 43.5 37.1
2000-07 female 112.6 45.6 39.0
2000-04 male 116.2 NA NA
2000-05 female 120.2 52.5 48.4
2000-06 female 127.4 49.6 43.2
attach(qdata)
> lmresult <- lm( BodyWeight ? sei )
> anova(lmresult)
Analysis of Variance Table
Response: BodyWeight
Df Sum Sq Mean Sq F value Pr(>F)
sei 1 364.82 364.82 5.4215 0.04828 *
Residuals 8 538.33 67.29
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
最終更新年月日 2006年4月10日
佐賀大学農学部動物生産学研究室ywada@cc.saga-u.ac.jp