ggplot2

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ggplot2

James Henson
Dear R Community,

Below is a problem with a simple ggplot2 graph. The code returns the error
message below.

Error: stat_count() must not be used with a y aesthetic.

My code is below and the data is attached as a ‘text’ file.



# Graph of the probabilities

library(digest)

library(DT)

datatable(probability)

str(probability)

probability$Fertilizer <- as.factor(probability$Fertilizer)

str(probability)

library(ggplot2)

plot1 <- ggplot(probability, aes(x=Fertilizer, y=prob)) +
geom_bar(aes(fill=Treatment))

plot1



Thanks.

Best regards,

James F. Henson

______________________________________________
[hidden email] 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.

probability.txt (364 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ggplot2

Huzefa Khalil
Hi James,

If you want to specify the y-values, you need to use stat="identity" as below:

ggplot(probability, aes(x=Fertilizer, y=prob)) +
geom_bar(stat="identity", aes(fill=Treatment))


best,
huzefa

On Tue, Apr 12, 2016 at 1:02 PM, James Henson <[hidden email]> wrote:

> Dear R Community,
>
> Below is a problem with a simple ggplot2 graph. The code returns the error
> message below.
>
> Error: stat_count() must not be used with a y aesthetic.
>
> My code is below and the data is attached as a ‘text’ file.
>
>
>
> # Graph of the probabilities
>
> library(digest)
>
> library(DT)
>
> datatable(probability)
>
> str(probability)
>
> probability$Fertilizer <- as.factor(probability$Fertilizer)
>
> str(probability)
>
> library(ggplot2)
>
> plot1 <- ggplot(probability, aes(x=Fertilizer, y=prob)) +
> geom_bar(aes(fill=Treatment))
>
> plot1
>
>
>
> Thanks.
>
> Best regards,
>
> James F. Henson
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: ggplot2

James Henson
Thanks, the stat="identity" worked.

On Tue, Apr 12, 2016 at 3:34 PM, Huzefa Khalil <[hidden email]>
wrote:

> Hi James,
>
> If you want to specify the y-values, you need to use stat="identity" as
> below:
>
> ggplot(probability, aes(x=Fertilizer, y=prob)) +
> geom_bar(stat="identity", aes(fill=Treatment))
>
>
> best,
> huzefa
>
> On Tue, Apr 12, 2016 at 1:02 PM, James Henson <[hidden email]> wrote:
> > Dear R Community,
> >
> > Below is a problem with a simple ggplot2 graph. The code returns the
> error
> > message below.
> >
> > Error: stat_count() must not be used with a y aesthetic.
> >
> > My code is below and the data is attached as a ‘text’ file.
> >
> >
> >
> > # Graph of the probabilities
> >
> > library(digest)
> >
> > library(DT)
> >
> > datatable(probability)
> >
> > str(probability)
> >
> > probability$Fertilizer <- as.factor(probability$Fertilizer)
> >
> > str(probability)
> >
> > library(ggplot2)
> >
> > plot1 <- ggplot(probability, aes(x=Fertilizer, y=prob)) +
> > geom_bar(aes(fill=Treatment))
> >
> > plot1
> >
> >
> >
> > Thanks.
> >
> > Best regards,
> >
> > James F. Henson
> >
> > ______________________________________________
> > [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.