为什么不是';t str_count使用多个字符串?

为什么不是';t str_count使用多个字符串?,r,string,substr-count,R,String,Substr Count,我有一个字符串,文本如下: Text <- c("How are you","What is your name","Hi my name is","You ate your cake") 我试着使用str_count函数,但是没有出现“you”和“your” 为什么str_count不能正常工作?将模式作为一个字符串传递 stringr::str_count(tolower(Text),'you|your') #[1] 1 1 0 2 将模式作为一个字符串传递 stringr::st

我有一个字符串,文本如下:

Text <- c("How are you","What is your name","Hi my name is","You ate your cake")
我试着使用str_count函数,但是没有出现“you”和“your”


为什么str_count不能正常工作?

模式作为一个字符串传递

stringr::str_count(tolower(Text),'you|your')
#[1] 1 1 0 2

模式作为一个字符串传递

stringr::str_count(tolower(Text),'you|your')
#[1] 1 1 0 2
stringr::str_count(tolower(Text),'you|your')
#[1] 1 1 0 2