我想创建多个直方图,如下图所示
这是数据集: https://drive.google.com/file/d/0B4Mldbnr1-avLUg1REJRRzFUZU0/view?usp=sharing
这是我到目前为止所做的代码,但是回来了错误:
source("load_data.R")
#library(lattice)
load_data <- function() {
data <- "E:/Intro Data Science/ClassActivity/Lab Session 5&6/dataset.txt"
data <- read.table(data, header=TRUE, sep=";", colClasses=c("numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric", "numeric"))
}
par(mfrow = c(3,1), mar=c(4, 4, 3,1))
hist (subset(data, globalActivePower==0)$SubMetering2, col = "red")
hist (subset(data, globalActivePower==1)$SubMetering2, col = "red")
hist (subset(data, globalActivePower==2)$SubMetering2, col = "red")
错误消息是
Error in hist.default(subset(data, globalActivePower == 0)$SubMetering2, :
'x' must be numeric
提前致谢 感谢你的帮助,欢呼声