R: Plot multiple box plots using columns from data frame

后端 未结 3 1305
慢半拍i
慢半拍i 2020-12-10 02:54

I would like to plot an INDIVIDUAL box plot for each unrelated column in a data frame. I thought I was on the right track with boxplot.matrix from the sfs

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 03:13

    You could use the reshape package to simplify things

    data <- data.frame(v1=rnorm(100),v2=rnorm(100),v3=rnorm(100), v4=rnorm(100))
    library(reshape)
    meltData <- melt(data)
    boxplot(data=meltData, value~variable)
    

    or even then use ggplot2 package to make things nicer

    library(ggplot2)
    p <- ggplot(meltData, aes(factor(variable), value)) 
    p + geom_boxplot() + facet_wrap(~variable, scale="free")
    

提交回复
热议问题