I have a dataframe
âdf â
with 3 columns. Details
âof df are â
as follows
> summary(df)
Date TestVar type
Min. :2002-05-10 00:00:00 Min. :-3.8531 Bottom: 313
1st Qu.:2005-05-09 12:00:00 1st Qu.:-0.7773 Other :2501
Median :2008-05-07 00:00:00 Median : 0.2482 Top : 313
Mean :2008-05-07 00:00:00 Mean : 0.1980
3rd Qu.:2011-05-05 12:00:00 3rd Qu.: 1.2250
Max. :2014-05-05 00:00:00 Max. : 3.6633
> str(df)
'data.frame': 3127 obs. of 3 variables:
$ Date : POSIXlt, format: "2002-05-10" "2002-05-13" "2002-05-14" ...
$ TestVar: num 1.34 2.02 1.39 1.54 2.45 ...
$ type : Factor w/ 3 levels "Bottom","Other",..: 3 3 3 3 3 3 3 3 2 2 ...
I have plotted the following density plot for column 2 i.e. TestVar and then
color coded according to factor variable "type"
<http://r.789695.n4.nabble.com/file/n4691999/Rplot01.jpeg>
> ggplot(df)+ geom_density(aes(x=TestVar, color=type))
I now want to filter out data samples such that the density
âcurve
of "Top" is
higher than "Bottom". Basically I need TestVar values for which blue line is
higher than red line.
How can this be achieved? Is there a way i can extract density values out of
the plot?
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
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.