0

I would like to append a different header to different data frames. But I do not know how to give different read.csv objects different names in a for loop. Can someone help me out?

Current code:

for (asset in 1:length(number_assets)) {
  
  ..... (asset?) <- read.csv(paste0("....",
                           asset, ".csv"),
                    header = F)
  
  newZ3 = seq(quantile(df[,asset], probs = 0.1), 
              quantile(df[,asset], probs = 0.9), length.out = 100)
  
  colnames(....) <- newZ3
}
Jacob
  • 1
  • 1
  • What is ```df_useful```? – maarvd Jun 10 '22 at 13:44
  • 1
    The best wat to deal with this is not to create a bunch of variables in your global environment and just keep everything in a named list. Something like this https://stackoverflow.com/questions/62037303/how-to-import-multiple-files-into-a-list-while-keeping-their-names – MrFlick Jun 10 '22 at 13:44
  • Would you explain what your `newZ3` is for in more detail? An example would be helpful. Also, you can have `dfs <- list()` outside the `for` loop, and inside the loop `dfs[[asset]] <- read.csv(...)` and then `colnames(dfs[[asset]]) <- ...` if you want to keep `number_assets` data frames. – chan1142 Jun 11 '22 at 05:59

0 Answers0