我想创建一个可以方便地接受数据框的函数,然后为数据框中的每个向量绘制一个直方图。对于每个额外的向量(除了第一个),我的函数还应该打印可能的几个散点图:向量参数列表中每个其他向量上的额外向量。
结果应该是一个三角形的地块阵列,最好是多面的。
这让我很难过。到目前为止,我有以下内容:
library(ggplot2)
library(reshape2)
scatterHistoChart <- function(data) {
require(ggplot2)
require(reshape2)
#data <- data.frame(...)
data <- melt(data)
graph <- ggplot(data,aes(x=value)) +
geom_histogram() +
# geom_point(aes(x=value)) +
facet_wrap(~variable,scales = "free_x")
return(graph)
}
scatterHistoChart(diamonds)
编辑
其中*
是直方图,+
是散点图,下面是预期结果的说明:
1-vec| *
2-vec| * +
3-vec| * + +
4-vec| * + + +
5-vec| * + + + +
等等请注意,地块的顺序并不重要;*
's 和' +
s 可以混用。