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
  • 相关阅读:
    springboot以jar运行时参数传递
    linux 下ab压力测试
    Quartus 11生成pof文件在AS烧写之后,程序无法启动
    芯片底层热焊盘的焊接
    CC3200模块的内存地址划分和bootloader,启动流程(二)
    python开发记录第一篇
    windows下使用Python出现No module named tkinter.ttk
    Pycharm设置Python的路径
    Qsys配置生成nios系统模块
    sprintf()函数使用异常
  • 原文地址:https://www.cnblogs.com/super-yb/p/11670074.html
Copyright © 2011-2022 走看看