r - Putting data frames into a list and then extracting them into seperate data frames -


this question has answer here:

i have made 3 data frames , put them list using command given below

# create 3 data frames bag <- round(data.frame(v1=rnorm(10),v2=rnorm(10,1,2)),2) book <- data.frame(a1=rnorm(10),a2=rnorm(10,1,2),a3=rep("na",10)) table <- round(data.frame(c1=rnorm(10),c2=rnorm(10,1,2)),2)  # create list list1 <- setnames(lapply(ls(pattern="bag|book|table"), function(x) get(x)), ls(pattern="bag|book|table")) 

i have performed operations on data frames in list , want extract data frames individual frames before going list. looking solution not have mention names of data frames again instead use same. example, first df in list should extracted in df named "book" , same others. can extract them one-by-one , rename them step looks redundant , not think efficient.

i appreciate towards solution.

thanks.

i think looking list2env:

bag <- round(data.frame(v1=rnorm(10),v2=rnorm(10,1,2)),2) book <- data.frame(a1=rnorm(10),a2=rnorm(10,1,2),a3=rep("na",10)) table <- round(data.frame(c1=rnorm(10),c2=rnorm(10,1,2)),2) # create list list1 <- setnames(   lapply(ls(pattern="bag|book|table"), function(x) get(x)),    ls(pattern="bag|book|table")) ## rm(bag, book, table) r> ls() #[1] "list1" ## list2env(list1, .globalenv) r> ls() #[1] "bag"   "book"  "list1" "table" 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -