[R] ggplot and boxplots

Richard M. Heiberger rmh at temple.edu
Tue Mar 13 05:59:17 CET 2018


It looks like your V3 is a factor.

testing_ggplot <- data.frame(
  V1=factor(c(256, 256, 256, 272, 272, 272)),
  V2=c("Disabled", "Disabled", "Enabled", "Disabled", "Enabled", "Enabled"),
  V3=681:686)

library(ggplot2)
ggplot(testing_ggplot, aes(V2,        V3 )) + geom_boxplot() +
facet_wrap( ~ V1) + labs(title="what you want")
ggplot(testing_ggplot, aes(V2, factor(V3))) + geom_boxplot() +
facet_wrap( ~ V1) + labs(title="what you are getting")

On Mon, Mar 12, 2018 at 4:28 PM, Yectli Huerta via R-help
<r-help at r-project.org> wrote:
> Hi,
>
> I was wondering if someone could give me a hint or two. I'm having problems generating ggplot2 boxplots . The plot that is has dots but no boxplots. Below is the dataset
>
>> testing_ggplot
>     V1        V2     V3
> 1  256  Disabled 688.61
> 2  256  Disabled 698.63
> 3  256  Disabled 700.02
> 4  256  Disabled 693.36
> 5  256  Disabled  688.8
> 6  256  Disabled 697.72
> 7  256  Disabled 698.15
> 8  256  Disabled 693.98
> 9  256  Disabled 700.75
> ...
> 16 256   Enabled 698.35
> 17 256   Enabled 694.71
> 18 256   Enabled 705.53
> 19 256   Enabled 708.61
> 20 256   Enabled 693.33
> ...
> 32 272  Disabled 690.79
>
> 33 272  Disabled 687.14
> 34 272  Disabled 684.92
> 35 272  Disabled 687.87
> 36 272  Disabled 687.33
> 37 272   Enabled 696.22
> 38 272   Enabled 700.61
> 39 272   Enabled  695.2
> 40 272   Enabled 697.46
> 41 272   Enabled 696.83
> ...
>
> This command for some reason, fails to generate a boxplot
>> ggplot(testing_ggplot,aes(factor(V2),V3))+geom_boxplot() +facet_wrap(~as.factor(V1))
>
> I don't seem to figure out what is wrong with the ggplot command I'm using. I attached a png with the generated plot
>
> thanks,
>
> yh
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list