zoukankan      html  css  js  c++  java
  • R in action -- chapter 9

      

    library(multcomp)
    View(cholesterol)
    attach(cholesterol)
    table(trt)
    by(cholesterol,trt,mean)
    
    aggregate(response,by=list(trt),mean)
    aggregate(response,by=list(trt),sd)
    fit <- aov(response ~ trt )
    summary(fit)
    library(gplots)
    plotmeans(response~trt,xlab = "treatment",ylab = "response",
              main="mean plot
    with 95% CI")
    
    aggregate(cholesterol$response,by=list(cholesterol$trt),FUN=mean)
    detach(cholesterol)
    
    TukeyHSD(fit)
    par(las=2)
    par(mar= c(5,8,4,2))
    plot(TukeyHSD(fit))
    
    library(multcomp)
    par(mar=c(4,4,4,3))
    tuk <- glht(fit,linfct=mcp(trt="Tukey"))
    plot(cld(tuk,level = .05),col = "lightgrey")
    
    library(car)
    qqPlot(lm(response ~ trt , data = cholesterol),simulate = TRUE, main = "QQ plot",labels=f)
    
    bartlett.test(response~ trt ,data =cholesterol)
    
    library(car)
    outlierTest(fit)
    
    data(litter, package = 'multcomp')
    attach(litter)
    table(dose)
    aggregate(weight,by= list(dose),mean)
    fit <- aov(weight ~ gesttime+dose)
    summary(fit)
    
    library(multcomp)
    contrast <- rbind("non drug vs. drug" = c(3,-1,-1,-1))
    summary(glht(fit,linfct=mcp(dose=contrast)))
    
    detach(litter)
    
    fit <- aov(weight ~ gesttime*dose,data = litter)
    summary(fit)
    
    library(HH)
    ancova(weight~gesttime+dose,data=litter)
    
    attach(ToothGrowth)
    table(supp,dose)
    aggregate(len, by=list(supp,dose),FUN=mean)
    len          
    aggregate(len,by=list(supp,dose),FUN=sd)
    dose=factor(dose)
    dose
    fit <- aov(len ~ supp*dose)
    summary(fit)
    detach(ToothGrowth)
    
    interaction.plot(dose,supp,len,type='b',
                     col=c('red','blue'),pch=c(16,18),
                     main='interaction betwwen dose and supplement type')
    library(gplots)
    plotmeans(len ~ interaction(supp, dose,sep = ' '),
              connect = list(c(1,3,5),c(2,4,6)),
              col=c('red','darkgreen'),
              main='interaction plot eith 95% CIS',
              xlab = 'treatment anf dose combination')
    library(HH)
    interaction2wt(len~supp*dose)
    
    CO2$conc <- factor(CO2$conc)
    W1b1 <- subset(CO2,Treatment=='chilled') # 
    fit <- aov(uptake~conc*Type + Error(Plant/(conc)),W1b1)
    summary(fit)
    par(las=2)
    par(mar=c(10,4,4,2))
    with(W1b1,interaction.plot(conc,Type,uptake,
                               type = 'b',col = c('red','blue'),pch=c(16,18),
                               main='interaction plot for plant type and concentration'))    
    boxplot(uptake~Type*conc,data=W1b1,col=(c('gold','green')),
            main='chilled quebec and mississippi panlts',
            ylab='carbon dioxide uptake rate (umol/m^2 sec)')
    

      

    Valar morghulis
  • 相关阅读:
    从属性赋值到MVVM模式详解
    C#综合揭秘——细说事务
    Action与Trigger
    C#综合揭秘——细说多线程(下)
    继承BitmapSource并使用独立存储来缓存远程的图片
    Windows Phone 7 MVVM模式数据绑定和传递参数
    Lambda表达式总结
    Windows Phone页面导航和独立存储开发总结
    RegisterHotKey设置系统级热键《转》
    隐藏统计代码或者任何不想被看见的东西《转》
  • 原文地址:https://www.cnblogs.com/super-yb/p/11670074.html
Copyright © 2011-2022 走看看