#For all functions below, you can use "?function" to see more options for each function. #e.g. ?png, or ?hist, etc. #Remember to set your working directory to where your files are located. #Save your pairwise relatedness values as a .csv file (see my file as an example). AENP_FDS_Wang <- read.csv("AENP_FDS_Wang_InputforR.csv", #Load csv file into R. header = T) #Yes, it has headers. png("AENP_FDS_Wang_histogram.png", #call the png driver make a .png file to which the plot will be saved. Give a name to the file. width = 10, #width in inches (see units) of the .png file height = 6.5, #height in inches units = "in", #units of width and height pointsize = 10, #font size to be used for axes labels and titles res = 600, #resolution of .png. 600 dots-per-inch (dpi). type = "cairo", #creat .png using cairographics instead of standard Windows GDI. antialias = "default") #a method to smooth out lines, so they are less "jaggy". hist(AENP_FDS_Wang$FullDataSet, #Plot the "FullDataSet" column of the data set. main = "Distribution of AENP Relatedness - Full Data Set", #Title of the plot. axes = F, #Don't plot the axes (we will add them later with the "axis" function). xlim = c(-1, 1), xlab = "Relatedness (Wang)", #Title of the x-axis. breaks = 300, #The number of "bins" to put the data into - you can play around with this to get a nice graph. probability = T) #Plots probability densities instead of actual counts - required if you want to add a density line to the plot later. axis(1, #add x-axis at = c(-1, -0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75, 1), #make tick marks at these points labels = c("-1.0", "-0.75", "-0.5", "-0.25", "0.0", "0.25", "0.5", "0.75", "1.0"), #Label the tick marks with these labels (you can leave this out and it will add two zeros after the decimal, but then it looks crowded on the x-axis). xpd = T) #allow the x-axis tick marks to extend beyond the plotting area. axis(2) #add y-axis. You can adjust the tick marks manually as for the x-axis, but I just left it as is. lines(density(AENP_FDS_Wang$FullDataSet), #add the density line for the data set. col = "red", #make it red lwd = 2) #line width of 2. dev.off() #switch the .png driver off, otherwise you won't be able to open the .png file, because it is still 'open' in R.