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

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

** 上图显示示例数据列表,所以我只想记录特定内容的关键字结尾,如(联系人);在那一行。 **

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)

我们可以转义 () \(contact\);$ 并将其用作模式

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

默认情况下,() 将被识别为元字符以将字符捕获为一组。 $ 是表示字符串结束的元字符