Is there a way to select one item in a list at a time? I've attempted this with the get() function, but I did not have any luck. I have 3537 character items in a list. I would like to select one character item at a time, run a set of code on using that item, then move on to another in a for loop. What might be an efficient way to accomplish this?
l <- dbListTables(mydb)
random_tables <- sample(3537, 300, replace = TRUE)
plot_list <- vector('list', 300)
for (i in seq_along(random_tables)){
# Reads the selected table in database
ind <- dbReadTable(mydb, get(l))
# Other code...
...
}
If l
are the name of the tables, you can do :
l <- dbListTables(mydb)
random_tables <- sample(l, 300)
plot_list <- vector('list', 300)
for (i in seq_along(random_tables)){
# Reads the selected table in database
ind <- dbReadTable(mydb, random_tables[i])
# Other code...
#...
}