【发布时间】:2019-10-24 21:54:26
【问题描述】:
我有一个列表列表,其中一些列表的名称是重复的,即使列表中的信息本身并不相同。这是一个例子:
l.f[[" c225 && Gross Amount && Reporting Year of Account 2015 && 225 && Gross Amount && Reporting Year of Account 2016 && 225 && Gross Amount && Reporting Year of Account 2016 && 1"]]
l.f[[" c225 && Gross Amount && Reporting Year of Account 2015 && 225 && Gross Amount && Reporting Year of Account 2016 && 225 && Gross Amount && Reporting Year of Account 2016 && 2"]]
l.f[[" c225 && Gross Amount && Reporting Year of Account 2015 && 225 && Gross Amount && Reporting Year of Account 2016 && 225 && Gross Amount && Reporting Year of Account 2016 && 3"]]
在这种情况下,唯一区别这些列表名称的是每个列表名称中的最后一个数字(1,2,3)。我想做的是分解这些列表的名称,以便它们的命名如下:
l.f[[" c225 && Gross Amount && Reporting Year of Account 2015"]]
l.f[["225 && Gross Amount && Reporting Year of Account 2016"]]
l.f[["225 && Gross Amount && Reporting Year of Account 2016 1"]]
有没有办法在 R 中像这样分解它?
【问题讨论】:
-
所有相似的字符串是否以相同的方式相似,只是末尾的数字不同?
-
@TimBiegeleisen 是的,唯一能区分它们的是末尾的数字,范围从 1 到 7,具体取决于列表名称