Getting TRUE in str_detect for the pattern which is not present. Checking for dot(.) as the pattern in the population column of data frame
#data frame
tab<- data.frame(
state=c("Alabama","Alaska","Arizona","Arkansas","California"),
population=c("4,853,875"," 737,709","6,817,565","2,977,853","38,993,940"),
total=c("348","59","309","181","1,861"),
murder_rate= c(7.2,8.0,4.5,6.1,4.8)
)
library(tidyverse)
str_detect(tab$population,".") #checking for pattern = .
#output: TRUE TRUE TRUE TRUE TRUE
checked also for pattern = ',' it's giving TRUE again.
str_detect(tab$population,",")
#output: TRUE TRUE TRUE TRUE TRUE
Not sure what is wrong?