I want a create a treatment variable that takes the value of 1 for treated countries and 0 otherwise. I know how to do this individually for each country with transform
but I was wondering if I can also add a vector to make it faster? I tired the following but I got an error (Warning: longer object length is not a multiple of shorter object length)
countries_vector <- c("USA", "UK", "ESP", "FR", "ITA")
df <- transform(df, treated = ifelse(Country == countries_vector, 1, 0))