[R] Warning message: Computation failed in `stat_bin()`: attempt to apply non-function

John Kane jrkrideau at inbox.com
Fri Mar 18 17:39:10 CET 2016


> ggplot(x=aes(friend_count), data=pf) + geom_histogram()

The x= in the above statement is wrong

ggplot(aes(friend_count), data=pf) + geom_histogram()
will work but it looks funny.


The more common way to write the command would likely be:
ggplot(pf, aes(friend_count)) + geom_histogram()


The tat_bin() message is  just a warning.
Your data set has ~ 99,000 rows of data and geom_histogram() 's default is 30 bins which is probably too few to for you to see what is happening.  Come to 

Change the default binwidth to something a bit more manageable or perhaps use geom_density() to look at the distribution.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: shahab.mokari at gmail.com
> Sent: Thu, 17 Mar 2016 19:01:19 +0100
> To: r-help at r-project.org
> Subject: [R] Warning message: Computation failed in `stat_bin()`: attempt
> to apply non-function
> 
> Hi,
> 
> I am trying to plot a sample dataset using ggplot2, but I am keep getting
> the following error message and an empty plot!
> Apparently something is wrong in the dataset, but what?
> 
> R :
> pf<-read.csv('pseudo_facebook.tsv', sep='\t')
> 
> ggplot(x=aes(friend_count), data=pf) + geom_histogram()
> 
> stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
> Warning message:
> Computation failed in `stat_bin()`:
> attempt to apply non-function
> 
> The dataset can be found at :
> https://s3.amazonaws.com/udacity-hosted-downloads/ud651/pseudo_facebook.tsv
> 
> thanks,
> /Shahab
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list