阅读此处的评论后,我在 sparkTable 包的 0.9.4 版本中包含了直方图。基本上与上一个答案建议的风格相同。
这里有两个例子:
1)仅用于绘制 sparkHist(不是很令人兴奋)
2) 用于为正态和对数正态分布数据创建带有箱线图和直方图的 sparkTable
#Example newSparkHist
hh <- newSparkHist(values=rnorm(100))
plotSparks(hh, outputType='pdf', filename='testHist1')
#Example sparkTable with Hist+Box with 2 variables in 10 different groups
datEx <- data.frame(variable=sample(paste("Cat",1:10,sep="_"),1000,replace=TRUE),
value=rnorm(1000),value2=rlnorm(1000))
b <- newSparkBox()
h <- newSparkHist()
content <- list(function(x) { round(mean(x),2) },
function(x) { round(median(x),2) },
function(x) { round(quantile(x,.25),2) },
function(x) { round(quantile(x,.75),2) },
b,
h,
function(x) { round(mean(x),2) },
function(x) { round(median(x),2) },
function(x) { round(quantile(x,.25),2) },
function(x) { round(quantile(x,.75),2) },
b,
h
)
names(content) <- c(paste(c("Mean","Median","Q25","Q75","Boxplot","Histogram"),
"_v1",sep=""),
paste(c("Mean","Median","Q25","Q75","Boxplot","Histogram"),"_v2",sep="")
)
varType <- c(rep("value",length(content)/2),rep("value2",length(content)/2))
datEx <- reshapeExt(datEx,idvar="variable", varying=list(2,3))
x2 <- newSparkTable(datEx, content, varType)
plotSparkTable(x2, outputType="html", graphNames="o2",filename="t1")