I have the dataframe below and I want to find the average for every level/factor of Area
column based on the month of Closed_Date
. So actually I want a new dataframe that the Columns Area
, Date
(year and month) and Average Sold Price
.
subs<-structure(list(Sold_Pr = c(6500, 173000, 60000, 73000, 155000,
105000, 140000, 39900, 73500, 46000, 99900, 180000, 164000, 120000,
206000, 160000, 67400, 215000, 145000, 175000, 350000, 425000,
435000, 490000, 545000, 585000, 170000, 229900, 652000, 472500,
520000, 690000, 320000, 560000, 710000, 632000, 680000, 439000,
770000, 725000, 580000, 775000, 490000, 470000, 605000, 640000,
563000, 575000, 620000, 520000), Area = structure(c(1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L), .Label = c("411",
"415", "981", "8001", "8002", "8003", "8004", "8005", "8006",
"8007", "8008", "8009", "8010", "8011", "8012", "8013", "8014",
"8015", "8016", "8017", "8018", "8019", "8020", "8021", "8022",
"8023", "8024", "8025", "8026", "8027", "8028", "8029", "8030",
"8031", "8034", "8035", "8037", "8038", "8039", "8040", "8041",
"8042", "8043", "8044", "8045", "8046", "8047", "8048", "8049",
"8050", "8051", "8052", "8053", "8055", "8056", "8057", "8058",
"8059", "8060", "8061", "8062", "8063", "8064", "8065", "8066",
"8067", "8068", "8069", "8070", "8071", "8072", "8073", "8074",
"8075", "8076", "8077"), class = "factor"), Closed_Date = structure(c(18668,
18933, 18716, 18740, 18639, 18845, 18708, 18676, 18733, 18695, 18715, 18709, 18794, 18803, 18750, 18787, 18906, 18810, 18855,
18870, 18626, 18786, 18808, 18864, 18961, 18914, 18865, 18704,
18661, 18747, 18676, 18659, 18696, 18802, 18689, 18873, 18836,
18809, 18823, 18851, 18967, 18893, 18660, 18626, 18810, 18655,
18661, 18719, 18647, 18863), class = "Date")), row.names = c(NA,
50L), class = c("tbl_df", "tbl", "data.frame"))