R 的多元图形推荐

发布于 2025-01-07 14:37:38 字数 162 浏览 1 评论 0原文

您能否推荐在任何可用的 R 包中使用四个变量可视化数据的最佳方法。

也就是说,我有两个分类变量(人口(12)和字符(50))和两个连续变量(100 个个体(矩阵中的行)的每个字符长度测量的平均值和变异系数)。所以它基本上是一个 12x50x100x100 维图。

有什么建议吗?

Could you please recommend the best way to visualize data with four variables in any of the available R packages.

Namely, I have two categorical variables(populations(12) and characters(50)) and two continuous variables (mean and coefficient of variation of each character length measurement for 100 individuals (rows in a matrix)). So it is basically a 12x50x100x100 dimensional graph.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陪我终i 2025-01-14 14:37:38

我会先逐个绘制变量,然后一起绘制,
从全体人口开始,逐步
将数据分成不同的组。

# 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
)

I would plot the variables first one by one, then together,
starting with the whole population and progressively
slicing the data into the various groups.

# 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
)
舂唻埖巳落 2025-01-14 14:37:38

如果您想沿着数据的一个维度或另一个维度绘制一系列“切片”,请考虑格子
为什么不访问 http://addictedtor.free.fr/graphiques/ 看看是否有人编写了一些代码来创建您想要的图表?

Consider lattice if you want to plot a series of "slices" along one dimension or another of your data.
Why not pop on over to http://addictedtor.free.fr/graphiques/ and see if someone's written some code to create the kind of graph you want?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文