0
PAR_SENS <- read.csv("PAR_FULL YEAR.csv")
attach(PAR_SENS)


#Eliminate 0s
View(PAR_SENS)
PAR_DAY <- filter(PAR_SENS,  Calibrated > 0)
View(PAR_DAY)
class(PAR_DAY$Date)
#make R read Date as a date
PAR_DAY$Date <- as.Date(PAR_DAY$Date)
class(PAR_DAY$Date)

#P.ONK AND L.INS CALC EXP JAN 2016

#Sort by Flumes
#New data.frame for each flume for just Jan-Mar 2016
F1 <- filter(PAR_DAY, Flume == 1)
View(F1)
class(F1$Date)

The above is code for some analysis that I am trying to do. I have a column labeled Date and a column labeled Calibrated. There are multiple values of Calibrated per Date and almost a year's worth of dates. I have filtered out 0's from my data, and made sure that Date is read by r as a date. Now I would like to filter out data for Calibrate by Date by using data between two dates. I have tried to make variables for each date (D1 and D2) and using the subset function e.g.:

 D1 <- as.Date(F1$Date, 04/01/2016)
 D2 <- as.Date(F1$Date, 03/03/2016)
 F1_JM <- subset(F1, D1:D1)

However, this returned an error, saying that "In D1:D2 : numerical expression has 6506 elements: only the first used". I am unsure of a better way to do this. Could someone help? I am relatively new to R coding. I could be forgetting some simple syntax.

Jaap
  • 81,064
  • 34
  • 182
  • 193
J. Manning
  • 11
  • 1
  • 1
    [Please make your example reproducible](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610) – Jaap Dec 28 '16 at 21:28
  • 1
    Normally, `F1[F1$Date > as.Date('2016-01-04') & F1$Date < as.Date('2016-03-03') , ]` would be sufficient as far as I can judge now – Jaap Dec 28 '16 at 21:31
  • 1
    Possible duplicate of [Subset a dataframe between 2 dates in R (Better Way)](http://stackoverflow.com/questions/23622338/subset-a-dataframe-between-2-dates-in-r-better-way). Also useful: http://stackoverflow.com/questions/28335715/r-how-to-filter-subset-a-sequence-of-dates and http://stackoverflow.com/questions/14471640/r-subset-by-date – PereG Dec 28 '16 at 21:32
  • My apologies, I'm new to this forum. I will make sure my next post is reproducible. I have looked at the other posts you have recommended, but was unable to get the code to work for my data set. I also tried the code above, but it returned a data set with 0 rows. I'll keep digging around for another way to do this. – J. Manning Dec 28 '16 at 21:58
  • @J.Manning Do not worry and welcome to SO. I hope we have helped you. – PereG Dec 29 '16 at 08:24

0 Answers0