簡體   English   中英

數據集每一列的分隔箱線圖

[英]Separated Boxplots for each column of a dataset

我有一個79列的數據框。

對於每一列,我試圖生成一個完全分開的箱線圖。

我試過了apply(integers, 2,function(x) boxplot(x, main = colnames(integers["x"])))

但是,我不能將每列的標題添加到相應的箱線圖中。

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