For such Data Frame, I was trying to select some rows within a specific date range:
nasdaq=read.csv("nasdaq.csv")
head(nasdaq)
Date Close.Price
1 2013-08-05 3692.95
2 2013-08-06 3665.77
3 2013-08-07 3654.01
4 2013-08-08 3669.12
5 2013-08-09 3660.11
6 2013-08-12 3669.95
what I have tried so far is:
chunk=subset(nasdaq,nasdaq$Date>=as.Date("2013-08-05") & nasdaq$Date<=as.Date("2018-08-03"))
Warning messages:
1: In eval(e, x, parent.frame()) :
Incompatible methods ("Ops.factor", "Ops.Date") for ">="
2: In eval(e, x, parent.frame()) :
Incompatible methods ("Ops.factor", "Ops.Date") for "<="
I have also tried...
chunk=nasdaq[nasdaq$Date>=as.Date("2013-08-05") & nasdaq$Date<=as.Date("2018-08-03"),]
Warning messages:
1: In `[.data.frame`(nasdaq, nasdaq$Date >= as.Date("2013-08-05") & :
Incompatible methods ("Ops.factor", "Ops.Date") for ">="
2: In `[.data.frame`(nasdaq, nasdaq$Date >= as.Date("2013-08-05") & :
Incompatible methods ("Ops.factor", "Ops.Date") for "<="
I have tried both of above without as.Date function but doesn't work, Please advise where I may be going wrong?
read.csv("nasdaq.csv", stringsAsFactors = F). That is step 1.