data <- data.frame(id = rep(1:3, each = 3), test = "Protein:creatinine ratio [Urine]", result = rep('4', 9))
I want to replace "Protein:creatinine ratio [Urine]" with "PCR":
data$test = str_replace_all(data$test, "Protein:creatinine ratio [Urine]", "PCR")
but it doesn't work.
Why is the string not being recognised for replacement?