I want to write a function that takes a dataframe, and graphs all the columns in that dataframe as histograms.
For a dataframe whose column names I know beforehand, I can write
qplot(colname1, data=df, geom='histogram')
qplot(colname2, data=df, geom='histogram')
...
but I want to do this generically, so that I can use the name of the column as a string "colname1"
.
In other words, how to write
plot_histogram_of_column <- function(df, colname) {
# qplot(colname, data=df, geom='histogram') won't work
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…