[R] Boxplots from data.frame
Sarah Goslee
sarah.goslee at gmail.com
Wed Jul 7 22:18:23 CEST 2010
What about this:
> testdata <- cbind.data.frame(value = runif(100), L1 = rep(1:10, each=10))
> head(testdata)
value L1
1 0.3370902 1
2 0.6766098 1
3 0.2433171 1
4 0.8848674 1
5 0.5253600 1
6 0.4067238 1
> tail(testdata)
value L1
95 0.8149121 10
96 0.5186669 10
97 0.1080695 10
98 0.6099110 10
99 0.6141373 10
100 0.3407369 10
> boxplot(testdata$value ~ testdata$L1)
Sarah
On Wed, Jul 7, 2010 at 4:11 PM, Ian Bentley <ian.bentley at gmail.com> wrote:
> Hi all,
>
> I'm trying to use ggplot to make a boxplot of some data, but I can't seem to
> figure out how to make it use the data I'm giving it.
>
> The data is in a data.frame so that it has two columns:
>
>>meltl
> value L1
> 1234 1
> 1234 1
> 1235 1
> ...
> 1255 1
> 2335 2
> 3444 2
> ...
> 10001 50
> 12311 50
> ...
>
> The first column is my x value, the second is my y.
>
> I'd like to produce one boxplot for each point on the graph, 50 in total
> (for this case). When I try something like:
>
> p <- ggplot(meltl, aes(L1, value))
> p + geom_boxplot()
>
> I get one giant boxplot, which tells me nothing much.
>
> Can anyone give me a helping hand?
>
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list