vendredi 19 juin 2020

Use if else statement for Dummy-Coding in R

I tried to create a If Else Statement to Recode my Variable in a Dummy-Variable.

I Know there is the ifelse() Function and the fastDummy-Package, but I tried this Way without succes.

Why does this not work? I want to learn and understand R in a better Way.

if(df$iscd115==1){
  df$iscd1151 <- 1
} else {
  df$iscd1151 <- 0
}

Aucun commentaire:

Enregistrer un commentaire