你能推荐在任何一个可用的R包中可视化具有四个变量的数据的最佳方法吗?
也就是说,我有两个分类变量(populations(12)和characters(50))和两个连续变量( 100个个体的每个字符长度测量的平均值和变异系数(矩阵中的行))。所以它基本上是一个12x50x100x100维图。
有什么建议吗?
发布于 2012-02-22 21:35:42
我将首先将变量逐个绘制出来,然后一起绘制,从整个总体开始,逐步将数据分成不同的组。
# Sample data
n1 <- 6 # Was: 12
n2 <- 5 # Was: 50
n3 <- 10 # Was: 100
d1 <- data.frame(
population = rep(LETTERS[1:n1], each=n2*n3),
character = rep(1:n2, each=n3, times=12),
id = 1:(n1*n2*n3),
mean = rnorm(n1*n2*n3),
var = rchisq(n1*n2*n3, df=5)
)
# Not used, but often useful with ggplot2
library(reshape2)
d2 <- melt(d1, id.vars=c("population","character","id"))
# Look at the first variable
library(lattice)
densityplot( ~ mean, data=d1 )
densityplot( ~ mean, groups=population, data=d1 )
densityplot( ~ mean | population, groups=character, data=d1 )
# Look at the second variable
densityplot( ~ var, data=d1 )
densityplot( ~ var, groups=population, data=d1 )
densityplot( ~ var | population, groups=character, data=d1 )
# Look at both variables
xyplot( mean ~ var, data=d1 )
xyplot( mean ~ var, groups=population, data=d1 )
xyplot( mean ~ var | population, groups=character, data=d1 )
# The plots may be more readable with lines rather than points
xyplot(
mean ~ var | population, groups = character,
data = d1,
panel = panel.superpose, panel.groups = panel.loess
)发布于 2012-02-22 20:32:50
如果您想沿着数据的一个维度或另一个维度绘制一系列“切片”,请考虑使用lattice。为什么不跳到http://addictedtor.free.fr/graphiques/上,看看是否有人编写了一些代码来创建您想要的图形呢?
https://stackoverflow.com/questions/9393986
复制相似问题