简体   繁体   English

数据集每一列的分隔箱线图

[英]Separated Boxplots for each column of a dataset

I have a data frame with 79 columns. 我有一个79列的数据框。

For each column, I am trying to produce an entirely separated boxplot. 对于每一列,我试图生成一个完全分开的箱线图。

I have tried apply(integers, 2,function(x) boxplot(x, main = colnames(integers["x"]))) 我试过了apply(integers, 2,function(x) boxplot(x, main = colnames(integers["x"])))

However, I cannot add the title of each column to the respective boxplot. 但是,我不能将每列的标题添加到相应的箱线图中。

library(tidyverse)


plot_function <- function(column_name, data_in) {

  plot_out <- ggplot(data_in, aes_string(y = column_name)) + 
    geom_boxplot() +
    labs(title = column_name)
  return(plot_out)

}

plot_columns <- names(iris)[1:4]

plot <- lapply(plot_columns, function(x, y) plot_function(x, y), y = iris)
plot[[1]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM