Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9206679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:13:35+00:00 2026-06-18T00:13:35+00:00

Consider the following lines. p <- ggplot(mpg, aes(x=factor(cyl), y=..count..)) p + geom_histogram() p +

  • 0

Consider the following lines.

p <- ggplot(mpg, aes(x=factor(cyl), y=..count..))

p + geom_histogram()   
p + stat_summary(fun.y=identity, geom='bar')

In theory, the last two should produce the same plot. In practice, stat_summary fails and complains that the required y aesthetic is missing.

Why can’t I use ..count.. in stat_summary? I can’t find anywhere in the docs information about how to use these variables.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T00:13:36+00:00Added an answer on June 18, 2026 at 12:13 am

    Expanding @joran’s comment, the special variables in ggplot with double periods around them (..count.., ..density.., etc.) are returned by a stat transformation of the original data set. Those particular ones are returned by stat_bin which is implicitly called by geom_histogram (note in the documentation that the default value of the stat argument is "bin"). Your second example calls a different stat function which does not create a variable named ..count... You can get the same graph with

    p + geom_bar(stat="bin")
    

    In newer versions of ggplot2, one can also use the stat function instead of the enclosing .., so aes(y = ..count..) becomes aes(y = stat(count)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

consider the following heatmap: df <- data.frame(a=rep(letters[1:10],10), b=rep(letters[1:10], each=10), c=sample(2,100, replace=TRUE)) ggplot(df, aes(a, b))
Consider the following lines of jQuery: var $s = $('<span><span class=one><span class=two></span></span></span>'); $('.one', $s).css('border',
I'm a bit puzzled about the conditional operator. Consider the following two lines: Float
Consider the following problem: A multi-line string $junk contains some lines which are encoded
Let's consider the following 3 code lines: struct stat buffer; status = lstat(file.c_str(), &buffer);
Consider the following Prolog code. It edits lines of a particular type in its
Consider the following mx:TextArea .. <mx:TextArea id=textArea/> .. periodically being updated with new lines
Consider the following lines of code: public interface IProduct { string Name { get;
Consider the following: me@mine:~$ cat a.sh #!/bin/bash echo Lines: $LINES echo Columns: $COLUMNS me@mine:~$
Consider the following ggplot2 graph with long facet/strip text broken in two lines. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.