I have a dataframe that has dates in the format YYYY/MM/DD
. I tried subseting it in two ways and got different values:
Method 1:
a <- mydata[(mydata$Date > 2010-01-01),]
Result:
This gave me results that include dates in 2008, 2009, etc.
Method 2:
a <- mydata[(mydata$Date > 2010/01/01),]
Result:
This gave me the correct results.
As you can see, the difference is the way I format the dates - "/" vs "-". Can someone explain to me what the difference is? The dates in the dataframe itself are in the form of YYYY-MM-DD
, which is why I used the hyphen in Method 1.