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

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

The above error pops up while drawing bar graph. I used mpg dataset to draw bar chart of displ vs cyl.
Aug 16 in Data Analytics by rayan
350 views

1 answer to this question.

0 votes

Hi Rayan,

This error comes due to the mapping of elements in aes() while plotting barplot.

geom_bar by default takes a count of values as y in a bar plot. So use stat="identity" within barplot() to avoid the default and use fields as used in mapping function.

ggplot(data,aes(field1,field2)) +geom_plot(stat="identity")
answered Aug 19 by anonymous
• 31,840 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Error saying "R Error: package ‘lme4’ required by ‘pbkrtest’ could not be found"

Windows 7, revo R 3.2.3 construct a directory ...READ MORE

answered Nov 9, 2018 in Data Analytics by Maverick
• 10,040 points
40 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
112 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
155 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
82 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
98 views
0 votes
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
129 views
0 votes
2 answers

How to remove rows with missing values (NAs) in a data frame?

Hi, The below code returns rows without ...READ MORE

answered Aug 20 in Data Analytics by anonymous
• 31,840 points
5,460 views