state1 <- "CA"
state2 <- "IL"
state3 <- "FL"
CA, IL, and FL are three data frames.
How to write a loop to remove these data frames using paste(“state”, i) where i is an integer? Assume there are many such data frames so that removing them one by one would be inefficient.
if you have names of the dataframes in character vector say
statesthen you can userm(list=states)Now there are various ways of getting
statesJust create it and update it when a new state variable is created.
e.g.
Or
If you have names of object in variables like
state1,state2etc.. then you can do what David suggested