如何在R中的列表中选择单词的一部分
我有一个列表,其中我有一些标准排序的最佳模型。我想获取变量的名称。例如,对于索引[1,1],我得到以下结果:如何在R中的列表中选择单词的一部分,r,string,list,R,String,List,我有一个列表,其中我有一些标准排序的最佳模型。我想获取变量的名称。例如,对于索引[1,1],我得到以下结果: 您可以对基本R选项使用sub: input <- "c...Intercept.....ICI....LC.. \"ICI\"" output <- sub("^.*\"(.*?)\".*$", "\\1", input) output [1] "ICI" 这可能会帮助你。。。 I just want the string be
您可以对基本R选项使用
sub
:
input <- "c...Intercept.....ICI....LC..
\"ICI\""
output <- sub("^.*\"(.*?)\".*$", "\\1", input)
output
[1] "ICI"
这可能会帮助你。。。
I just want the string between " ", i.e., the ICI.
What should I modify?
Thanks!
input <- "c...Intercept.....ICI....LC..
\"ICI\""
output <- sub("^.*\"(.*?)\".*$", "\\1", input)
output
[1] "ICI"
lapply(your_list, function(x) sub("^.*\"(.*?)\".*$", "\\1", x))