楼主: lanhong1993
1075 6

[问答] 如何分词? [推广有奖]

  • 1关注
  • 1粉丝

已卖:286份资源

博士生

54%

还不是VIP/贵宾

-

威望
0
论坛币
2701 个
通用积分
3.4261
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
12167 点
帖子
214
精华
0
在线时间
141 小时
注册时间
2016-11-1
最后登录
2024-3-26

楼主
lanhong1993 发表于 2019-8-19 16:29:20 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请教大家,比如我有一列文本数据(如下英文,只是某个单元格的内容),每个单元格都有这么多文字。我现在想把文本中的Conclusions这个关键词之后的文字保留,并单独作为一列,Conclusions之前的文字都舍弃。这用R该怎么做呢?

PATIENT/TEST INFORMATION:
Indication: 78 year-old man with atrial fibrillation off anticoagulation, please evaluate for thrombus.
Height: (in) 66
Weight (lb): 130
BSA (m2): 1.67 m2
BP (mm Hg): 163/63
HR (bpm): 80
Status: Inpatient
Date/Time: [**2173-9-2**] at 09:47
Test: Portable TTE (Complete)
Doppler: Full Doppler and color Doppler
Contrast: None
Technical Quality: Adequate

Conclusions:
The left atrium is mildly dilated. No left atrial mass/thrombus seen (best
excluded by transesophageal echocardiography). The right atrium is moderately
dilated. There is mild symmetric left ventricular hypertrophy. The left
ventricular cavity is mildly dilated. There is moderate global left
ventricular hypokinesis (LVEF = 30%). [Intrinsic left ventricular systolic
function is likely more depressed given the sever



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝


沙发
katymeala 发表于 2019-8-20 01:26:47
library(stringr)
str_extract(data, "Conclusions.+")

data就是你的数据(向量)
已有 1 人评分论坛币 收起 理由
jiangbeilu + 10 精彩帖子

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

藤椅
lanhong1993 发表于 2019-8-20 17:04:29
katymeala 发表于 2019-8-20 01:26
library(stringr)
str_extract(data, "Conclusions.+")
您好,谢谢您的回复。这样似乎不行的,跑出来的结果是这样的:
[1] "Conclusions:" "Conclusions:" "Conclusions:" "Conclusions:" "Conclusions:" "Conclusions:"
我是想要把“Conclusions”之后的内容都提取出来。

板凳
jiangbeilu 学生认证  发表于 2019-8-20 22:43:24
lanhong1993 发表于 2019-8-20 17:04
您好,谢谢您的回复。这样似乎不行的,跑出来的结果是这样的:
[1] "Conclusions:" "Conclusions:" "Con ...
给你一个例子:
  1. library(stringr)
  2. test <-  "Conclusions:
  3. we are best"
  4. test
  5. test2 = gsub("\n"," ",test)
  6. str_extract(test2, "Conclusions:.+")
复制代码
跑一下你应该能知道答案

报纸
surfw 发表于 2019-8-21 08:26:55
考虑文本中有回车符。
  1. > library(stringr)
  2. > s <-  "PATIENT/TEST INFORMATION:
  3. + Indication: 78 year-old man with atrial fibrillation
  4. + off anticoagulation, please evaluate for thrombus.
  5. +
  6. + Conclusions:
  7. + The left atrium is mildly dilated. No left atrial
  8. + mass/thrombus seen (best excluded by
  9. + transesophageal echocardiography)."
  10. > cat(s)
  11. PATIENT/TEST INFORMATION:
  12. Indication: 78 year-old man with atrial fibrillation
  13. off anticoagulation, please evaluate for thrombus.

  14. Conclusions:
  15. The left atrium is mildly dilated. No left atrial
  16. mass/thrombus seen (best excluded by
  17. transesophageal echocardiography).
  18. > s1 <- str_extract(s, "(?<=Conclusions:\n)[\\s\\S]*")
  19. > cat(s1)
  20. The left atrium is mildly dilated. No left atrial
  21. mass/thrombus seen (best excluded by
  22. transesophageal echocardiography).
复制代码


地板
lanhong1993 发表于 2019-8-21 10:37:00
jiangbeilu 发表于 2019-8-20 22:43
给你一个例子:跑一下你应该能知道答案
万分感谢!!

7
lanhong1993 发表于 2019-8-21 10:39:43
surfw 发表于 2019-8-21 08:26
考虑文本中有回车符。
感谢!!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-2-27 10:51