我已创建集群,我想通过一个循环创建几种图表GGPLOT2看到我的结果。
到目前为止是这种情况,但我想创建我的每一个变量,而不是“BonusTrans”的同一个图
ggplot(data = airlinesNorm, aes(x = BonusTrans, fill=clusters)) +
geom_histogram( position="identity",alpha=0.5, binwidth = 1) +
scale_fill_manual(values=colorPalette)
我试图用for循环和lapply但没有工作。
plotClusters=function(var) {
ggplot(data = airlinesNorm, aes(x = var, fill=clusters)) +
geom_histogram( position="identity",alpha=0.5, binwidth = 1) +
scale_fill_manual(values=colorPalette) }
lapply(airlinesNorm[1:7], function(var) plotClusters(var))
错误:
不知道怎么自动拾取规模类型功能的对象。 默认为连续错误data.frame(X =函数(X,Y = NULL,na.rm = FALSE,使用):参数意味着不同的行数:0,3999
请指教 :)