0

I have the following data set: here is a sample

    Date    Site    Flow
    14/10/2014  B1  NA
    28/10/2014  B1  NA
    31/10/2014  B1  0.118433346
    04/11/2014  B1  NA
    10/11/2014  B1  NA
    18/11/2014  B1  NA
    25/11/2014  B1  NA
    18/12/2015  B1  NA
    14/10/2014  B2  NA
    28/10/2014  B2  NA
    31/10/2014  B2  NA
    04/11/2014  B2  NA
    10/11/2014  B2  0.315115017
    18/11/2014  B2  NA
    25/11/2014  B2  0.160140626
    18/12/2015  B2  NA
    14/10/2014  B5  0.324
    28/10/2014  B5  0.2136
    31/10/2014  B5  NA
    04/11/2014  B5  0.5239608
    10/11/2014  B5  0.52866
    18/11/2014  B5  NA
    25/11/2014  B5  3.3144
    18/12/2015  B5  3.2472
    14/10/2014  B7  NA
    28/10/2014  B7  NA
    31/10/2014  B7  NA
    04/11/2014  B7  0.09893448
    10/11/2014  B7  0.26321832
    18/11/2014  B7  NA
    25/11/2014  B7  0.058483968
    18/12/2015  B7  0.213892704

This is the code I have used:

mydata <- read.csv("FlowlsBar.csv", header = T)
L <- names(mydata) %in% c("B1", "B2", "B5")
O <- mydata[!L]
O$Flow <-as.numeric(O$Flow)
O$Date <- as.POSIXct(as.Date(O$Date, "%d/%m/%Y"))
O$Site <- factor(O$Site, levels=c("B1", "B2", "B5"), labels=c("B1", "B2", "B5"))
I <- ggplot(data=O, aes(x=Date, y=Flow, line=Site, shape=Site)) + 
geom_point() + geom_line() +
labs(title = "Flow in the Barlwyd 2014-2015",
x = "Month 2014/2015",
   y = "Flow(Log 10 L m3s)") +
scale_x_datetime(breaks=date_breaks("1 month"),labels =   date_format("%m"))+
  facet_wrap(~Site, nrow= 1)
r3<- I + coord_trans(y = "log10")   
r4<- r3 + scale_y_continuous(breaks = c(0, 0.1, 1, 2.5), labels = c(0,    0.1, 1, 2.5))
ggdraw(r4)

The graph I get is enter image description here

How do I remove the NA portion of the graph from facet_wrap? Perhaps there is another way to subset to only include the site factors that I need?

Thankyou in advance, Happy hat thinking!

LucySHE
  • 387
  • 1
  • 3
  • 9
  • Hover over the R tag - it asks for a minimal reproducible example. [Here's a guide](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#answer-5963610). Please edit & improve your question accordingly so that one can copy and paste your data and code to reproduce the image. – lukeA Jan 11 '17 at 11:18
  • Hi I've just given the minimum as I don't want to release my data set quite yet. – LucySHE Jan 11 '17 at 11:31
  • 3
    You should be able to provide a subset as input to ggplot: `I <- ggplot(data=O[ !is.na(O$Site), ]...` – rosscova Jan 11 '17 at 11:32
  • Thankyou rosscova- That works perfectly! :-) – LucySHE Jan 11 '17 at 11:36
  • @LucySHE You can create a dummy data set or use one of the build in sets. Read the guide for future postings. – lukeA Jan 11 '17 at 12:45
  • By the way, `I` is a function in R, so you might to avoid naming your data `I`. – Axeman Jan 11 '17 at 12:56

0 Answers0