Download and Load Data

Create Histogram Plot Function

# this function will create a histogram of every variable in your data frame
# the function takes one argument ('data') which is the name of your data frame
# if you want to save the scatter plots as .png files define the file path for graphs_folder below
# you will also need to remove the "#" from the two lines in the function that are commented out and place a "#" before print
# save graphs in this folder
graphs_folder <- '/filepath/graphs/'
hist <- function(x, na.rm = TRUE, ...) {
nm <- names(x)
for (i in seq_along(nm)) {
print(ggplot(x,aes_string(x = nm[i])) + geom_histogram(alpha=.8, fill = "darkblue") + theme_classic()) }
#plots <- ggplot(x,aes_string(x = nm[i])) + geom_histogram(alpha=.8, fill = "darkblue") + theme_classic()
#ggsave(plots,filename=paste(graphs_folder, "hist_",nm[i],".png",sep=""))}
}