I am dealing with a dataset like:
ID Status par1 par2 par3
1 Z 0.1 0.05 0.06
2 Z 0.3 0.34 1.2
3 C 0.4 0.5 0.8
...
Here, the 'Status' column indicates case/control status ('Z' for cases and 'C' for controls). The dataset is attached as 'dataset'.
Is there a way to gain two box plots (with "jitterred" points) for each parameter (par1 to par3) and each status?
I've tried
p <- ggplot()
p <- p + layer(data = dataset, geom = c("jitter", "boxplot"), mapping = aes(x = Status, y = par1)
and already I run into the problem that I only see jittered points, but no boxplot. Also, I did not figure out how to create a facet plot for arbitrary parameters (par1 to parx).
Any pointers for me?
TIA
Christian
Christian
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Anyway...
This gets you the jittered points and boxplot.
#############
require(ggplot2)
dataset <- read.csv('/Users/brandonhurr/Desktop/data.csv')
ggplot(data = dataset, aes(x = Status, y = par1)) + geom_boxplot()+geom_jitter()
ggsave("test.png", dpi = 200)
###############You'll need to melt your dataset using reshape
##############
require(reshape2)
m.dataset<-melt(dataset, id.vars=c("ID", "Status"), value.name="par")
ggplot(data = m.dataset, aes(x = Status, y = value)) +
geom_boxplot()+
geom_jitter()+
facet_grid(.~variable)+
labs(x="X axis Title", y="Yaxistitle, Status")
##############
HTH,
Brandon
2011/11/22 Meesters, Christian <mees...@aesku.com>
>
> I did not speak of any attached dataset. Anyway, here it is, including a minimal example. No meaningful data and also too few, but the main point gets visible: There are only jittered points, no boxplots. The same is true for larger datasets.
> Also, I do not know how to display this pair of case / control boxplots for all parameters (I might not know the parameter names in advance).
>
> Thanks,
> Christian
>
>
> ________________________________
> From: Brandon Hurr [brando...@gmail.com]
> Sent: Monday, November 21, 2011 6:24 PM
> To: Meesters, Christian
> Cc: ggp...@googlegroups.com
> Subject: Re: boxplot + jitter -- display problem for multiple parameters
Brandon
On Tue, Nov 22, 2011 at 08:49, Meesters, Christian <mees...@aesku.com> wrote:
> Oh, indeed, "attach" in R-related mailing lists should be used with little more caution. Stupid me.
>
> Anyway, your snippet does the trick. I was unaware of reshape2 - thanks a lot.
>
> Cheers,
> Christian
>
> ________________________________________
> From: Brandon Hurr [brando...@gmail.com]
> Sent: Tuesday, November 22, 2011 9:32 AM
Anyway, your snippet does the trick. I was unaware of reshape2 - thanks a lot.
Cheers,
Christian
________________________________________
From: Brandon Hurr [brando...@gmail.com]
Sent: Tuesday, November 22, 2011 9:32 AM