I have this data in a flat file-
State Date HasASale
CA 2013-01-01 1
SC 2013-01-01 1
NY 2013-02-01 1
MN 2013-03-01 1
WA 2013-04-01 1
CA 2013-05-01 1
SC 2013-05-01 1
It is a many to many relation for state to date.
Which months have most sales? Which state has most sales?
I want to be able to plot the results.
I am using R to get this information. I am able to read the information-
hm <- read.table("states.data", header=T, sep="")
df <- data.frame(hm$Date,hm$States, hm$HasASale)
az <- with(df, zoo(hm.Freq, hm.Date))
df.TS <- aggregate(az, as.yearmon, sum)
df.sts <- aggregate(az, list(h=hm$States), sum)
This gives me the aggregates. How can I get the top 20 states by sales. Or top 20 sale dates?