# Read values from tab-delimited files aaatariderraw_data <- read.table("AAATA-Fixed-Route-Ridership.tsv", header=T, sep="\t") # Define colors to be used plot_colors <- rainbow(12) date_day <- Sys.Date() go_pass_year_names <- c("go_pass_FY_2004","go_pass_FY_2005","go_pass_FY_2006","go_pass_FY_2007","go_pass_FY_2008","go_pass_FY_2009","go_pass_FY_2010","go_pass_FY_2011","go_pass_FY_2012","go_pass_FY_2013","go_pass_FY_2014") total_year_names <- c("Total_Fixed_Route_FY_2004","Total_Fixed_Route_FY_2005","Total_Fixed_Route_FY_2006","Total_Fixed_Route_FY_2007","Total_Fixed_Route_FY_2008","Total_Fixed_Route_FY_2009","Total_Fixed_Route_FY_2010","Total_Fixed_Route_FY_2011","Total_Fixed_Route_FY_2012","Total_Fixed_Route_FY_2013","Total_Fixed_Route_FY_2014") um_year_names <- c("UM_FY_2004","UM_FY_2005","UM_FY_2006","UM_FY_2007","UM_FY_2008","UM_FY_2009","UM_FY_2010","UM_FY_2011","UM_FY_2012","UM_FY_2013","UM_FY_2014") bar_labels <- c("FY2004","FY2005","FY2006","FY2007","FY2008","FY2009","FY2010","FY2011","FY2012","FY2013","FY2014") file_name <- paste("AAATA-Ridership-go-pass-annual", date_day,".png",sep="") png(filename=file_name, height=500, width=1500, bg="white") #bottom, left, top and right #par(mai=c(1.1,0.5,0.5,0.9)) par(mar=c(7,6,6,20)) year_total <- sum(aaatariderraw_data$go_pass_FY_2004) for (i in 2:11){ year <- go_pass_year_names[i] year_total <- as.numeric(c(year_total, sum(aaatariderraw_data[[year]]))) } barplot(year_total, col="red", ylim=c(0,750000), axes=FALSE, names.arg=bar_labels, cex.names=1.5, font=2) graph_title <- paste("Annual Totals AAATA Fixed Route Ridership\n (Go!Pass Boardings)") y <- seq(0,750000,100000) axis(2, at = y, labels = formatC(y, big.mark = ",", format = "d"), las = 1, font=2, cex.axis=1.5) title(main=graph_title, col.main="black", font.main=2, cex.main=2.5) mtext("Data from the AAATA", side = 1, line = 4, outer = FALSE, cex=0.9, font=2) box() dev.off() ###### file_name <- paste("AAATA-Ridership-M-Ride-annual", date_day,".png",sep="") png(filename=file_name, height=500, width=1500, bg="white") #bottom, left, top and right #par(mai=c(1.1,0.5,0.5,0.9)) par(mar=c(7,6,6,20)) year_total <- sum(aaatariderraw_data$UM_FY_2004) print(year_total) for (i in 2:11){ year <- um_year_names[i] year_total <- as.numeric(c(year_total, sum(aaatariderraw_data[[year]]))) } barplot(year_total, col="darkgoldenrod1", ylim=c(0,3000000), axes=FALSE, names.arg=bar_labels, cex.names=1.5, font=2) graph_title <- paste("Annual Totals AAATA Fixed Route Ridership\n (M-Ride Boardings)") y <- seq(0,3000000,500000) axis(2, at = y, labels = sprintf("%s M", formatC(y/1000000, digits=1, , format="f", big.mark = ".")), las = 1, font=2, cex.axis=1.5) title(main=graph_title, col.main="black", font.main=2, cex.main=2.5) mtext("Data from the AAATA", side = 1, line = 4, outer = FALSE, cex=0.9, font=2) box() dev.off() ####### file_name <- paste("AAATA-Ridership-Total-annual", date_day,".png",sep="") png(filename=file_name, height=500, width=1500, bg="white") #bottom, left, top and right #par(mai=c(1.1,0.5,0.5,0.9)) par(mar=c(7,6,6,20)) year_total <- sum(aaatariderraw_data$Total_Fixed_Route_FY_2004) for (i in 2:11){ year <- total_year_names[i] year_total <- as.numeric(c(year_total, sum(aaatariderraw_data[[year]]))) } barplot(year_total, col="black", ylim=c(0,7000000), axes=FALSE, names.arg=bar_labels, cex.names=1.5, font=2) graph_title <- paste("Annual Totals AAATA Fixed Route Ridership\n (Total Boardings)") y <- seq(0,7000000,1000000) #axis(2, at = y, labels = formatC(y, big.mark = ",", format = "d"), las = 1, font=2, cex.axis=1.5) axis(2, at = y, labels = sprintf("%s M", formatC(y/1000000, digits=1, , format="f", big.mark = ".")), las = 1, font=2, cex.axis=1.5) title(main=graph_title, col.main="black", font.main=2, cex.main=2.5) mtext("Data from the AAATA", side = 1, line = 4, outer = FALSE, cex=0.9, font=2) box() dev.off()