'How to have all my paths in list object after running a for loop? [closed]

I am more a python user than an R script writer. In my current project I am using R. I have multiple pathsets, for multiple samples, and I wanted to make my code less dense.

dir.path <- "/home/gwenneg/Projet_Spatial/"
file.list <- list("13H01640", "13H08091", "14H04547", "15H24261", "16H25543", "17H15169","G71246", "H03J73","H20567", "H21057", "H41-178" , "H46280" , "H48D81", "H50743")
data.path <- "/outs/"
i <- list(seq(1, length(file.list)))
for (elt in i){
  x <- sprintf("pathset_%s", elt)
}

for (file.name in file.list){
  for (j in x){
      j <- list(paste0(dir.path, file.name, data.path))
  }
}

The problem with this code portion is that : in my final j object, I only find the last element of the file.list.

Does anyone know how I should do to get all the elements from file.list into the j list ?

Thanks you in advance for your insight and help :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source