简体   繁体   English

R读取csv文件我只想以该行结尾的一列以特定字符串值结尾

[英]R reading csv file i want to only one column with that row end with specific string value

在此处输入图片说明 ** above image showing sample data list, so i want to get only record that content specific keyword end like (contact); ** 上图显示了示例数据列表,因此我只想记录该内容特定的关键字结尾,如(联系人); on that row.在那一行。 ** **

data <- read.csv("csv.csv", sep = ',')

# Get the max salary from data frame.
Piname <- data$col_NAME
print(Piname)
poname <- Piname[str_detect(Piname,"(end_string);")]
print(poname)

#summary(warnings())

tail(warnings(), 50)

We can either escape the () \\\\(contact\\\\);$ and use it as pattern我们可以转义() \\\\(contact\\\\);$并将其用作模式

Piname[str_detect(Piname, "\\(contact\\);$")]

as by default, the ( or ) would be recognized as metacharacters to capture the characters as a group.默认情况下, ()将被识别为元字符以将字符捕获为一个组。 The $ is a metacharacter to signify the end of string $是表示字符串结束的元字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM