This question is related to my previous one, Subsetting a dataframe for a specified month and year
I use the command
sales <- read.csv("mysales.csv", colClasses="character")
to obtain a dataframe which looks like this:
row date pieces income
1 21/11/2011 49 220.5
2 22/11/2011 58 261
3 23/11/2011 23 103.5
4 24/11/2011 57 256.5
I want to create a subset for November 2011 using the code provided in my previous question, but various attempts have failed. So for a check I wrote in the console:
format.Date(sales[1,1], "%Y")=="2011"
and the answer was:
[1] FALSE
Moreover:
format(as.Date(sales[1,1]), "%d/%m/%Y")
[1] "20/11/21"
How can I, at least, know what is happening with date format?
What should I do to subset the dataframe using code like:
subset(sales, format.Date(date, "%m")=="11" & format.Date(date, "%Y")=="2011")
Sorry if my question is not clear, but the problem I am facing is not clear to me either.
(Edit to correct formatting)