The R Project SVN R

Rev

Rev 25599 | Rev 42333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 25599 Rev 27716
Line 27... Line 27...
27
}
27
}
28
\seealso{
28
\seealso{
29
  \code{\link{evalq}}, \code{\link{attach}}.
29
  \code{\link{evalq}}, \code{\link{attach}}.
30
}
30
}
31
\examples{
31
\examples{
-
 
32
require(stats); require(graphics)
32
#examples from glm:
33
#examples from glm:
33
\dontrun{
34
\dontrun{
34
library(MASS)
35
library(MASS)
35
data(anorexia)
36
data(anorexia)
36
with(anorexia, {
37
with(anorexia, {
Line 41... Line 42...
41
}
42
}
42
 
43
 
43
with(data.frame(u = c(5,10,15,20,30,40,60,80,100),
44
with(data.frame(u = c(5,10,15,20,30,40,60,80,100),
44
                lot1 = c(118,58,42,35,27,25,21,19,18),
45
                lot1 = c(118,58,42,35,27,25,21,19,18),
45
                lot2 = c(69,35,26,21,18,16,13,12,12)),
46
                lot2 = c(69,35,26,21,18,16,13,12,12)),
46
    list(summary(glm(lot1 ~ log(u), family=Gamma)),
47
    list(summary(glm(lot1 ~ log(u), family = Gamma)),
47
         summary(glm(lot2 ~ log(u), family=Gamma))))
48
         summary(glm(lot2 ~ log(u), family = Gamma))))
48
 
49
 
49
# example from boxplot:
50
# example from boxplot:
50
data(ToothGrowth)
51
data(ToothGrowth)
51
with(ToothGrowth, {
52
with(ToothGrowth, {
52
    boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
53
    boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
53
            subset= supp == "VC", col="yellow",
54
            subset = (supp == "VC"), col = "yellow",
54
            main="Guinea Pigs' Tooth Growth",
55
            main = "Guinea Pigs' Tooth Growth",
55
            xlab="Vitamin C dose mg",
56
            xlab = "Vitamin C dose mg",
56
            ylab="tooth length", ylim=c(0,35))
57
            ylab = "tooth length", ylim = c(0,35))
57
    boxplot(len ~ dose, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2,
58
    boxplot(len ~ dose, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2,
58
            subset= supp == "OJ", col="orange")
59
            subset = supp == "OJ", col = "orange")
59
    legend(2, 9, c("Ascorbic acid", "Orange juice"),
60
    legend(2, 9, c("Ascorbic acid", "Orange juice"),
60
           fill = c("yellow", "orange"))
61
           fill = c("yellow", "orange"))
61
})
62
})
62
 
63
 
63
# alternate form that avoids subset argument:
64
# alternate form that avoids subset argument:
64
with(subset(ToothGrowth, supp == "VC"),
65
with(subset(ToothGrowth, supp == "VC"),
65
     boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
66
     boxplot(len ~ dose, boxwex = 0.25, at = 1:3 - 0.2,
66
             col="yellow", main="Guinea Pigs' Tooth Growth",
67
             col = "yellow", main = "Guinea Pigs' Tooth Growth",
67
             xlab="Vitamin C dose mg",
68
             xlab = "Vitamin C dose mg",
68
             ylab="tooth length", ylim=c(0,35)))
69
             ylab = "tooth length", ylim = c(0,35)))
69
with(subset(ToothGrowth,  supp == "OJ"),
70
with(subset(ToothGrowth,  supp == "OJ"),
70
     boxplot(len ~ dose, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2,
71
     boxplot(len ~ dose, add = TRUE, boxwex = 0.25, at = 1:3 + 0.2,
71
             col="orange"))
72
             col = "orange"))
72
legend(2, 9, c("Ascorbic acid", "Orange juice"),
73
legend(2, 9, c("Ascorbic acid", "Orange juice"),
73
       fill = c("yellow", "orange"))
74
       fill = c("yellow", "orange"))
74
}
75
}
75
\keyword{data}
76
\keyword{data}
76
\keyword{programming}
77
\keyword{programming}