I have a dataframe titled FilteredData
with many columns. Specifically, there are two columns I am interested in: Date
and Sale number.
I want to group all Sale number
entries by dates. Date
is a date-type field, and Sale number
is a character-type field. If I'm not mistaken, I think these types are the reason why other Q&As on S.O. haven't been much help to me.
How can I do this?
I've tried the following:
aggregate(FilteredData$`Sale number`, by FilteredData$Date, FUN = count)
group_by(FilteredData$`Sale number`, FilteredData$Date)
Neither worked, and neither did the solution found here when I tried it.
I tried the following:
library(sqldf)
Freq = sqldf('SELECT Date, COUNT('Sale Number') FROM FilteredData GROUP BY Date')
and it surprisingly worked. However, is there a way to obtain this result without having to use SQL syntax, i.e. something "purely" in R?