zoukankan      html  css  js  c++  java
  • R语言实战

    > boxplot(mtcars$mpg, main="box plot", ylab="miles per gallon")
    > boxplot.stats(mtcars$mpg)
    $stats
    [1] 10.40 15.35 19.20 22.80 33.90
    
    $n
    [1] 32
    
    $conf
    [1] 17.11916 21.28084
    
    $out
    numeric(0)
    

    1. 使用并列箱型图进行跨组比较

    > boxplot(mpg ~ cyl, data=mtcars,
    +         main="cars mileage data",
    +         xlab="number of cylinders",
    +         ylab="miles per gallon")
    > 
    

    > boxplot(mpg ~ cyl, data=mtcars,
    +         notch=TRUE,
    +         varwidth=TRUE,
    +         col="red",
    +         main="Car Mileage Data",
    +         xlab="Number of Cylinders",
    +         ylab="Miles Per Gallon")
    

    > mtcars$cyl.f <- factor(mtcars$cyl,
    +                        levels=c(4,6,8),
    +                        labels=c("4","6","8"))
    > mtcars$am.f <- factor(mtcars$am,
    +                       levels=c(0,1),
    +                       labels=c("auto", "standard"))
    > boxplot(mpg ~ am.f *cyl.f,
    +         data=mtcars,
    +         varwidth=TRUE,
    +         col=c("gold", "darkgreen"),
    +         main="MPG Distribution by Auto Type",
    +         xlab="Auto Type")
    > 
    

    2. 小提琴图

    > library(vioplot)
    > x1 <- mtcars$mpg[mtcars$cyl==4]
    > x2 <- mtcars$mpg[mtcars$cyl==6]
    > x3 <- mtcars$mpg[mtcars$cyl==8]
    > vioplot(x1, x2, x3,
    +         names=c("4 cyl", "6 cyl", "8 cyl"),)
    Error in vioplot(x1, x2, x3, names = c("4 cyl", "6 cyl", "8 cyl"), ) : 
      argument is missing, with no default
    > vioplot(x1, x2, x3,
    +         names=c("4 cyl", "6 cyl", "8 cyl"),
    +         col="gold")
    > title("Violin Plots of Miles Per Gallon")
    > 
    

  • 相关阅读:
    php 基本符号
    php-fpm 启动和关闭
    php redis安装
    nginx 的安装
    Windows下Nginx的安装与配置
    apache 限制IP网段访问
    解决mysql导入导出数据乱码问题
    log_bin_trust_function_creators错误解决
    Mysqlbinlog使用
    通过yum安装Nagios
  • 原文地址:https://www.cnblogs.com/wnzhong/p/7589393.html
Copyright © 2011-2022 走看看