Вопрос

Не могли бы вы рекомендовать наилучшим способом визуализации данных с четырьмя переменными в любой из доступных пакетов R.

Именно у меня есть две категорические переменные (популяции (12) и символы (50)) и две непрерывные переменные (средние и коэффициент изменения каждого измерения длины символов для 100 человек (строки в матрице)).Так что это в основном диаграмма размером 12x50x100x100.

Любые предложения?

Это было полезно?

Решение

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
)

Другие советы

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?

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top