Argument "env" is missing, no default qplot or ggplot R

I have a dataset with three columns for which I am trying to plot a pdf for the column id. This is what part of my data looks like.

        day          ID   count
        8754     48112050     1
        8975     48112050     3
        8327     61010046     2
        8346     61010046  3997
        8506     61010046     1
        8605     61010046     1

      

I am using qplot for this:

qplot(count, colour=factor(ID), data=df, geom="density")

      

or ggplot:

ggplot(df, aes(x=count, colour= ID))+geom_density()

      

but it doesn't display PDF for all ids. When I enter, I realize that the only ids missing from the plot generated by qplot or ggplot are IDs that have no more than 2 occurrences in my data. In this example ID: 48112050.

I am plotting density for this id only and it works.

         day          ID   count
        8754     48112050     1
        8975     48112050     3

      

However, when I restrict my df to just including that ID, or any ID with two occurrences, qplot or ggplot gives me the following error:

Error in exists(name, envir = env, mode = mode) : 
argument "env" is missing, with no default

      

Does this mean that qplot / ggplot requires at least 3 points to plot the density function?

+3


source to share


1 answer


It looks like it ggplot2_1.0.1

requires at least three points to estimate the density. However, this behavior seems to have changed in the github repository since this commit on June 12, 2010. A version was posted in March and is currently on CRAN. I'm not sure when to expect the next release ggplot2

. You can try to pull the source directly from github if needed for you,



+2


source







All Articles