如何将多个列切片到boxplot?

时间:2016-11-20 03:27:46

标签: r dataframe extract multiple-columns slice

我有以下数据enter image description here

我尝试使用以下命令绘制一个列并且它可以正常工作。但是,在尝试绘制几列时,该命令不起作用

#this works but only for one column boxplot(as.numeric(new[[2]]), horizontal = T, col = "lightblue", notch = T, main="Heart Failure Mortality")

#does not work, I am trying to get the first 3 columns boxplot(as.numeric(new[[c(1:3)]]))

1 个答案:

答案 0 :(得分:0)

您没有显示new的结构,并且您的语法表明您正在尝试将其列视为列表元素。

只需确保它是带有数字列的数据框。

boxplot(iris[,1:4])

给出了此数据框的4个数字列的箱线图