This question already has an answer here:
How can I apply the same function to multiple data frames in R without having to save the data frames into a new list? I don’t want to have to type out manually the names of the data frames, that I am applying the function against. I don’t want to have to type:
data_frame2 = myfunction(data_frame2)
….Over and over. I might have 30 dataframes I want to do this too. I dont want to have to extract them out of a list.
data_frame.2 = mtcars
data_frame.111 = mtcars
data_frame.12345 = mtcars
my_function(dataset){
names(adjusted_dataset)= toupper(names(dataset))
return(adjusted_dataset)
}
my_dfs = ls(pattern = “data_frame.*”) # I know all my data frames in memory start with “data_frame”
How can I make use of sapply(my_dfs, my_function)
here?