Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中的模式匹配后选择以下字符_R_Regex_String_Split - Fatal编程技术网

在R中的模式匹配后选择以下字符

在R中的模式匹配后选择以下字符,r,regex,string,split,R,Regex,String,Split,我有一个数据框架,其中有一列文本,其中包含我需要提取的信息,下面是该列中的一个观察结果:每个问题都有三个与it目标、关键结果和责任相关的属性 [{"text":"Newideas.","translationKey":"new.question-4","id":4,"objectives":"Great","KeyResults":"Awesome","responsible":"myself"},{"text":"customer focus.","translationKey":"new.q

我有一个数据框架,其中有一列文本,其中包含我需要提取的信息,下面是该列中的一个观察结果:每个问题都有三个与it目标、关键结果和责任相关的属性

[{"text":"Newideas.","translationKey":"new.question-4","id":4,"objectives":"Great","KeyResults":"Awesome","responsible":"myself"},{"text":"customer focus.","translationKey":"new.question-5","id":5,"objectives":"Goalset","KeyResults":"Amazing","responsible":"myself"}
-------------------------期望输出-----------------------

Question#   Objectives KeyResults responsible Question#   Objectives KeyResults responsible 
4            Great      Awesome    myself       5           Goalset    Amazin     myself

数据是有效的
json
(但需要在其上用方括号括起来
]
)。您可以使用json解析器包将json读入R对象(例如,
jsonlite

假设您的文本位于数据框
df
text
列中,那么这将把该文本转换为R数据框

library(jsonlite)

dat <- fromJSON(df$text)
dat

#              text translationKey id objectives KeyResults responsible
# 1       Newideas. new.question-4  4      Great    Awesome      myself
# 2 customer focus. new.question-5  5    Goalset    Amazing      myself

请使用
dput
演示示例如果您提供了一个简单的示例输入和所需的输出,可用于测试和验证可能的解决方案,则会更容易为您提供帮助。
install.packages("jsonlite")