I have a data.table "temp"
library(data.table)
library(stringr)
temp <- data.table(name=c("test1","test2","test3","test4"),
country=c("usa","usa","mexico","mexico"))
I want to apply function to column "name" where country is "usa" in data.table way.
For example apply function str_replace()
from stringr
:
str_replace( temp[country == "usa"]$name ,'\\w*[a-z]', '')
any advice or links are welcome!