Hi David,
You "just" need to learn how to subset your data.frame, see functions
like ?subset and ?"[", as well as a good guide to understand the subtleties!
Some graphic functions also have a built-in argument to subset within
the function (e.g. argument 'subset' in 'plot.formula'), although the
ggplot() function doesn't seem to have it.
In any case, I would recommend you spend some time learning that aspect,
as you will always need it in one situation or another.
HTH,
Ivan
--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra
On 29/11/2017 22:07, David Doyle wrote:
Say I have a dataset that looks like
Location Year GW_Elv
MW01 1999 546.63
MW02 1999 474.21
MW03 1999 471.94
MW04 1999 466.80
MW01 2000 545.90
MW02 2000 546.10
The whole dataset is at http://doylesdartden.com/ExampleData.csv
and I use the code below to do the graph but I want to do it without MW01.
How can I remove MW01??
I'm sure I can do it by SubSeting but I can not figure out how to do it.
Thank you
David
--------------------------------------------------------------
library(ggplot2)
MyData <- read.csv("http://doylesdartden.com/ExampleData.csv", header=TRUE,
sep=",")
#Sets whic are detections and nondetects
MyData$Detections <- ifelse(MyData$D_GW_Elv ==1, "Detected", "NonDetect")
#Removes the NAs
MyDataWONA <- MyData[!is.na(MyData$Detections), ]
#does the plot
p <- ggplot(data = MyDataWONA, aes(x=Year, y=GW_Elv , col=Detections)) +
geom_point(aes(shape=Detections)) +
##sets the colors
scale_colour_manual(values=c("black","red")) + #scale_y_log10() +
#location of the legend
theme(legend.position=c("right")) +
#sets the line color, type and size
geom_line(colour="black", linetype="dotted", size=0.5) +
ylab("Elevation Feet Mean Sea Level")
## does the graph using the Location IDs as the different Locations.
p + facet_grid(Location ~ .)
[[alternative HTML version deleted]]
______________________________________________
R-help@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.
______________________________________________
R-help@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.