I have a list of groups that separates data by zipcode and months. I am having trouble plotting the data in a line graph.
data <- read.csv("./data/rental_12_11_2015_365.csv")
data$Listing.Contract.Date <- as.Date(data$Listing.Contract.Date, format = "%Y-%m-%d")
data$Month_Int <- as.numeric(strftime(data$Listing.Contract.Date,"%m"))
data$Month_Char <- month.abb[data$Month_Int]
groups_zipcode <- with(data, split(data, list(Zip.Code, Month_Char)))
summaryofgroups <- lapply(groups_zipcode, function(group){nrow(group)})
ggplot(data = groups_zipcode, aes(x=Month_Char, y=summaryofgroups, group=Zip.Code, col=Zip.Code)) + geom_line()
The output is what I have below but for all the months etc. I did not paste everything. The ggplot is producing "Error: ggplot2 doesn't know how to deal with data of class list".
$`75013.Apr`
[1] 11
$`75025.Apr`
[1] 39
$`75035.Apr`
[1] 71
$`75070.Apr`
[1] 103
$`75071.Apr`
[1] 43
$`75075.Apr`
[1] 15
$`75093.Apr`
[1] 13
$`75013.Aug`
[1] 18
$`75025.Aug`
[1] 39
$`75035.Aug`
[1] 80
$`75070.Aug`
[1] 93
$`75071.Aug`
[1] 49
$`75075.Aug`
[1] 16
$`75093.Aug`
[1] 19
Solution:
Hi I was able to find the solution. This was what I was trying to do. Good luck to anyone else in a similar situation.
inventory_graph <- ggplot(data = data, aes(x=Month_Char, fill = as.factor(Zip.Code))) + geom_histogram(position = "dodge")
summaryofgroups <- lapply(groups_zipcode, nrow)
– Axeman