我有一个关于研究人员从属关系的列,并且只想从Brazil
中提取这些从属关系。
下面是一个示例:
"Department of Neurology, Faculty of Medicine, University of São Paulo, São Paulo, Brazil; Gerontology, School of Arts, Sciences, and Humanities, University of São Paulo, São Paulo, Brazil; Graduate Program in Applied Statistics, University Center of United Metropolitan Colleges, São Paulo, Brazil; School of Health Sciences, Faculty of Medicine and Health Sciences, University of East Anglia, Norwich, United Kingdom; Human Cognitive Neuroscience, Psychology, University of Edinburgh, Edinburgh, United Kingdom; Neurology Division, University Hospital, Federal University of Minas Gerais, Belo Horizonte, Brazil; Neuroimaging Laboratory, School of Medical Sciences, University of Campinas (UNICAMP), Campinas, Brazil; Neurology Department, University of Campinas, Campinas, Brazil"
字符串
预期结果如下:
"Department of Neurology, Faculty of Medicine, University of São Paulo, São Paulo, Brazil; Gerontology, School of Arts, Sciences, and Humanities, University of São Paulo, São Paulo, Brazil; Graduate Program in Applied Statistics, University Center of United Metropolitan Colleges, São Paulo, Brazil; Neurology Division, University Hospital, Federal University of Minas Gerais, Belo Horizonte, Brazil; Neuroimaging Laboratory, School of Medical Sciences, University of Campinas (UNICAMP), Campinas, Brazil; Neurology Department, University of Campinas, Campinas, Brazil"
型
4条答案
按热度按时间bgtovc5b1#
您可以:
字符串
创建于2023-08-05使用reprex v2.0.2
lztngnrs2#
你也可以使用正则表达式来删除字符串中不包含'brazil'的部分:
字符串
其中,
型
编辑
要仅提取大学名称,请执行以下操作:
型
使用
stringr
包型
stringr中前面的代码
型
3lxsmp7m3#
我们可以使用
stringr
包。首先,拆分字符串上的“;”字符,字符串为str_split_1
。其次,使用str_subset
过滤特征向量。最后,使用str_flatten
将字符串“展平”到一起字符串
cbwuti444#
尝试
scan
+grep
,如下所示字符串
这给了
型
数据
型