Skip to content
Prev 334591 / 398506 Next

ifelse statement with two vectors of different length

Hi,

Suggestion 1: read
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
and bookmark it for future reference.

Suggestion 2:
set.seed(123)
countrydiff <- letters[1:5]
long_df <- data.frame(country_name = sample(letters[1:8], 20, replace=TRUE))

long_df$povdat <- as.numeric(long_df$country_name %in% countrydiff)

Sarah
On Wed, Dec 18, 2013 at 8:57 AM, Adel <adel.daoud at sociology.gu.se> wrote: