2016-11-10 15 views
0

Ich versuche Boxplots für eine Matrix (athTp) mit 6 Variablen (Spalten), aber mit vielen fehlenden Werten zu machen, 'Boxplots mit fehlenden Werten in R - ggplot

ggplot(athTp)+geom_boxplot() 

Aber vielleicht etw ich tue, falsch ...

Ich habe auch versucht, viele Box-Plots zu machen und danach das Raster zu arrangieren, aber die endgültige Handlung war sehr klein (in den gewünschten Dimensionen), viele Details verlierend.

q1 <- ggplot(athTp,aes(x="V1", y=athTp[,1]))+ geom_boxplot() 

..continue mit anderen 5 Spalten

grid.arrange(q1,q2,q3,q4,q5,q6, ncol=6) 

ggsave("plot.pdf",plot = qq, width = 8, height = 8, units = "cm") 

Haben Sie Ideen? Vielen Dank im Voraus!

Antwort

0
# ok so your data has 6 columns like this 
set.seed(666) 
dat <- data.frame(matrix(runif(60,1,20),ncol=6)) 
names(dat) <- letters[1:6] 
head(dat) 

# so let's get in long format like ggplot likes 
library(reshape2) 
longdat <- melt(dat) 
head(longdat) 

# and try your plot call again specifying that we want a box plot per column 
# which is now indicated by the "variable" column 
# [remember you should specify the x and y axes with `aes()`] 
library(ggplot2) 
ggplot(longdat, aes(x=variable, y=value)) + geom_boxplot(aes(colour = variable)) 

enter image description here

+0

..so das "Langformat" es war das Problem! Vielen Dank, es funktioniert jetzt! – Marz