1.
> p45Density<-ggplot(allbats,aes(x=allbats$count[allbats$species == "p45"]))
> print(p45Density + geom_density()+scale_x_continuous("Density of counts"))
Warning message:
Removed 9 rows containing missing values (stat_density).
2
> qplot(allbats$count[allbats$species == "p45"],geom="density", xlab="Density of Counts")
Warning message:
Removed 1 rows containing missing values (stat_density).
The former has a peak value of about 10-04, the latter 8-04
is the the first option removing all the rows with NAs even when there
isn't an NA in the variable I am interested in (p45), and the second
only removing the NA from the p45 variable
If this is the case, I wonder if someone could help with correct
syntax for ggplot2, as the qplot option is correct.
Many thanks,
Graham
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
Thanks for the quick reply, I have attached the data set, without a
context I don't think its that sensitive.
In fact I get an error with your suggestion.
> ggplot(allbats.p45 ,aes(x=allbats.p45$count)
+ + geom_density()
+ +scale_x_continuous("Density of counts"))
Error in aes(x = allbats.p45$count) + geom_density() :
non-numeric argument to binary operator
BUT the qplot version works fine, but it still seems to suggest its
related to NAs.
> qplot(allbats.p45$count
+ ,geom="density"
+ ,xlab="Density of Counts")
Warning message:
Removed 1 rows containing missing values (stat_density).
Graham
> Both of them give me the same error and graph so I'll go back and look at
> your previous program...
And they both work fine here as well :-)
I look forward to your feedback on my code, as I am obviously doing
something wrong.
Thanks,
Graham
Graham
I have just tried again, but copying and pasting the code in your email
> p45Density<-ggplot(allbats,aes(x=allbats$count[allbats$species=="p45"]))
> print(p45Density + geom_density()+scale_x_continuous("Density of counts"))
Warning message:
Removed 9 rows containing missing values (stat_density).
And I get the graph attached. I am on a Mac with Tiger which means I
am still running R 2.10.0 or am I ? Running R from ESS tells me its,
2.10.0 but running from the terminal tells me its R 2.9.2. Not sure
if this is relevant to this particular problem, but I probably need to
sort this out.
It does seem the problem is local to me, and obviously there is
something odd going on here.
Thanks again,
Graham
Graham
Thanks for this, its really useful, to see a slight twist on the
approach and to confirm my issues seem to be local ones.
Graham
Graham
> Here's the culprit:
>
> p45Density<-ggplot(allbats, aes(x=allbats$count[allbats$species=="p45"]))
>
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> You're asking ggplot to read in the entire allbats data frame, but then
> subsetting x. In fact, it's the other way around: subset the data frame and
> then select the variable.
Ah, thanks. I can see that now :-)
Graham