I want to run an analysis on a large number of subsets of an initial dataframe, each subsetted dataframe is named according to the subset they represent.
I have made a list of dataframes (below called dflist), and run a function on them, using the identifier "dataframe_in_list" in the for loop. I tried using "deparse(substitute(dataframe_of_interest)) as the title, but it is not taking the original title out, i.e. mtcars_a or mtcars_b.
mtcars_a <- mtcars[1:16,]
mtcars_b <- mtcars[16:32,]
plot_items <- function(dataframe_of_interest, item_x, item_y){
plot(dataframe_of_interest[, item_x], dataframe_of_interest[, item_y],
main = deparse(substitute(dataframe_of_interest)))
}
dflist <- list(mtcars_a, mtcars_b)
for (dataframe_in_list in dflist){
plot_items(dataframe_in_list, "mpg", "disp")
}
However, the titles of each graph are the identifier from the for loop, not the real dataframe it was originally from.
Any advice greatly appreciated!