Create a separate variable for each element of a list

后端 未结 1 547
走了就别回头了
走了就别回头了 2020-12-11 12:00

I have a list of data frames, which was produced from reading in 25 .csv files at once. I would like to unlist the data frames to begin a spatial analysis. That is, I woul

相关标签:
1条回答
  • 2020-12-11 12:24

    One way of doing it:

    list2env(setNames(l,paste0("df",seq_along(l))), envir = parent.frame()) 
    

    Though I would heed @baptiste 's advice before it is too late and avoid doing this. Why? Because in two days time you'll find yourself trapped using get() and paste and messy loops to try to apply a function to all of your datasets at once. If you keep them in a list you can just do lapply(l,functionname).

    0 讨论(0)
提交回复
热议问题