I have a table of data with a column representing a lab value for each study subject (rows).
I want to generate a series of histograms showing the distribution of v
You could generate the plots in a for loop with something like this, if your data frame is named "df" and you want to generate histograms starting with column 2 (if column 1 is your id):
for (col in 2:ncol(df)) {
hist(df[,col])
}
The hist function automatically calculates a reasonable bin width, or you can specify a fixed number of bins for all histograms, by adding the breaks argument:
hist(df[,col], breaks=10)
If you use RStudio, all your plots will be automatically be saved in the plots pane. If not, you will need to save each plot to a separate file inside the loop, as explained here: http://www.r-bloggers.com/automatically-save-your-plots-to-a-folder/