This is a very simple question, however I can't seem to come up w/ an answer. I would like to create a list of data frames
matching a pattern, then rm
these from the global environment.
The pattern to match is 'water_land_by_owntype_*
'
This is what I have tried, but it doesn't work...I think b/c it doesn't know where to search for the string.
rm (matches <- list(
grep('water_land_by_owntype_*')))
-al
Hi you can do like this :
# Create some data.frame
water_land_by_owntype_1 <- mtcars
water_land_by_owntype_2 <- mtcars
water_land_by_owntype_3 <- mtcars
water_land_by_owntype_4 <- mtcars
water_land_by_owntype_5 <- mtcars
# Put them in a list
water_land_by_owntype <- lapply(ls(pattern = "water_land_by_owntype_.*"), get)
# or more directly
water_land_by_owntype <- mget(ls(pattern = "water_land_by_owntype_.*"))
# Delete them
rm(list = ls(pattern = "water_land_by_owntype_.*"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With