R_tilde - RとLinuxと...

RとLinuxと...


R_tilde

Rの備忘録

Lattice Multivariate Data Visualization with R 10.1 ### p.166 \section{非標準評価} に

form <- ~ boxcox.trans(gcsescore, p) | gender

という自分では使ったことのないコードがある.ただし,ここでの事例は,動作しないということで紹介されている.

boxcox.trans <- function(x, lambda) {
     if (lambda == 0) log(x) else (x^lambda - 1) / lambda
 }

data(Chem97, package = "mlmRev")

trellis.device(pdf, file = "Chem97BoxCox.pdf", 
                width = 8, height = 6)

for (p in seq(0, 3, by = 0.5)) {
     plot(qqmath(~boxcox.trans(gcsescore, p) | gender,
   data = Chem97, 
       groups = score, f.value = ppoints(100), 
       main = as.expression(substitute(lambda == v, 
                                       list(v = p)))))
 }
dev.off()

# 以下は動作しない

form <- ~ boxcox.trans(gcsescore, p) | gender
qqboxcox <- function(lambda) {
     for (p in lambda)
         plot(qqmath(form, data = Chem97, 
            groups = score, f.value = ppoints(100), 
            main = as.expression(substitute(lambda == v, 
                                            list(v = p)))))
 }
qqboxcox(lambda = seq(0, 3, by = 0.5))
 
Link: Rの備忘録(1827d) R_scope_environment(3596d)
Last-modified: 2009-02-11 (水) 17:41:14 (3598d)