Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205301

applying function to multiple dataframes programatically [duplicate]

$
0
0

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?


Viewing all articles
Browse latest Browse all 205301

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>