Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. # Seems like there are some outliers so lets remove anything greater than 2.5 st. deviations from the mean
  2. sf <- sf[which(sf$SalePrice < mean(sf$SalePrice) + (2.5 * sd(sf$SalePrice))), ]
  3.  
  4. #violin plots
  5. home_value_violin <- ggplot(sf, aes(x=SaleYr, y=SalePrice, fill=SaleYr)) + geom_violin(color = "grey50") +
  6. xlab("Sale Price($)") + ylab("Count") +
  7. scale_fill_manual(values=pallete_7_colors) +
  8. stat_summary(fun.y=mean, geom="point", size=2, colour="white") +
  9. plotTheme() + theme(legend.position="none") +
  10. scale_y_continuous(labels = comma) +
  11. labs(x="Year",y="Sale Price($)",title="Distribution of San Francisco home prices",
  12. subtitle="Nominal prices (2009 - 2015); Sale price means visualized as points",
  13. caption="Source: San Francisco Office of the Assessor-Recorder\n@KenSteif & @SimonKassel")
  14. home_value_violin
  15. ggsave("plot2_violin.png", home_value_violin, width = 8, height = 4, device = "png")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement