############################################### # Extra coding ideas for fun or a challenge # #View dataframe View(NYBG_SP1) #note capital V #Pull up information about histogram fucntion ?hist() #Add color and border color to bars #Here is a list of possible colors in R: http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf h <- hist(NYBG_SP2$year, main = "Alliaria petiolata abundance over time", xlab = "Collection Year", xlim = c(1860,2020), ylim = c(0, 21), breaks = 15, col = "green") #Change border color of bars h <- hist(NYBG_SP2$year, main = "TITLE", xlab = "Collection Year", xlim = c(1860,2020), ylim = c(0, 21), breaks = 15, border = "blue") ##Add year labels to x-axis #First, create a string with the years you need. End before the last year in your data (e.g., if the data # end in 2014, your string ends with 2010) newstring = c(1870, 1880, 1890, 1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010) #Run your histogram as befoer, but change ylim to make room h <- hist(NYBG_SP2$year, main = "TITLE", xlab = "Collection Year", xlim = c(1860,2020), ylim = c(-1, 21), #change lower limit to -1 breaks = 15) #Add the label text text(x-location, y-location, what the labels are, 75% of the size of the rest of the text) text(h$mids, -1, labels = newstring, cex = 0.75) #you can also add the sample sizes above the bars with the original code #Pull up information about text fucntion for more info ?text()