楼主: yu9954
902 2

[有偿编程] R语言,如何提取某段文字中包含某个关键字的句子? [推广有奖]

  • 0关注
  • 1粉丝

大专生

73%

还不是VIP/贵宾

-

威望
0
论坛币
820 个
通用积分
2.0765
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
660 点
帖子
35
精华
0
在线时间
50 小时
注册时间
2018-11-22
最后登录
2023-10-23

20论坛币

variable 名为 ”test_result", 前三条结果如下:

[1] No recent territorial infarct, hydrocephalus, hyperdense intracranial  vessel, intracranial mass, midline shift or intracranial herniation.\r\r\n \r\r\n Small hypodensities in bilateral lentiform nuclei inferiorly are favored  to represent prominent perivascular spaces.\r\r\n Patchy low-attenuation in bilateral cerebral white matter, nonspecific but  likely represents mild chronic small vessel ischemic change. Generalized  age-related brain parenchymal volume loss

[2] Slight increase in the  ventricular volume but no transependymal hypodensity.  No new hemorrhage.   No mass effect. Midline is centered.\r\n \r\n \r\n"                                                               [3] There is increased mass effect upon the cortical  mantle but there is no midline shift.\r\n Right prefrontal subdural hematoma measures up to 3 mm in depth,  previously 4 mm in depth and has become increasingly low density.\r\n The ventricular system is unremarkable.\r\n No new hemorrhage or acute territorial ischemic insult is detected.\r\n Carotid siphon atheromatous calcification is detected.\r\n There is a left approach NG tube and paranasal sinus mucosal thickening.\r\n Unaltered calvarial fractures including bilateral petrous temporal bone  fractures resulting in fluid filling the mastoids.\r\n No abnormality of the globes/orbits is detected.\r\n \r\n \r\n"。。。。。。


(有几千个结果)                                                                     


想找出包含关键字“midline” 的句子,并产生一个新的变量(就是包含关键词的这句话),该怎么实现呢? 感谢大神们赐教   


最佳答案

s609078902 查看完整内容

这样就可以了
关键词:如何提取 关键字 R语言 Increasingly Territorial
沙发
s609078902 发表于 2021-11-12 14:58:22 |只看作者 |坛友微信交流群
这样就可以了
  1. new_variable <- stringr::str_subset(test_result, "midline")
复制代码
已有 1 人评分论坛币 收起 理由
cheetahfly + 10 热心帮助其他会员

总评分: 论坛币 + 10   查看全部评分

使用道具

藤椅
yu9954 发表于 2021-11-12 20:45:50 |只看作者 |坛友微信交流群
因为不是所有行都包含这个字符串,所以我这里报错了

Errors:
  replacement has 727 rows, data has 2177

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 15:03