Abbas Ali
Abbas Ali

Reputation: 1

Looping down a list of names and extracting data frame from a list of data frames

I have a list that stores 142 data frames I have extracted the names of them into a vector

d.names[1] [1] "ACQ_C.XPT"

I used a function to create a true/false vector which contains a list of variables in each data frame that I wish to either keep or discard

d1[1] $ACQ_C.XPT SEQN ACD010A ACD010B ACD010C ACQ020 ACQ030 ACD040 ACQ050 ACQ060 ACD070 ACD080 TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

I wish to iteratively go down the list of the data frames and create data frames that include only those variables marked as true in vector d1

lapply(seq_along(d.names),function(i,x){as.data.frame(x[,rapply(d1[i], 
function(x) list(x))])x=d.names[i]})

Error: unexpected symbol in "lapply(seq_along(d.names),function(i,x){as.data.frame(x[,rapply(d1[i], function(x) list(x))])x"

Upvotes: 0

Views: 25

Answers (0)

Related Questions