这是一个非常简单的问题,但我似乎无法给出答案。我想创建一个列表data frames
匹配一个模式,然后rm
这些来自全球环境。
要匹配的模式是 'water_land_by_owntype_*
'
这是我尝试过的,但它不起作用......我认为 b/c 它不知道在哪里搜索字符串。
rm (matches <- list(
grep('water_land_by_owntype_*')))
-al
你好,你可以这样做:
# 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_.*"))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)