In a data frame, a column named site(categorical column) has unique values(101,102,103,104,206,105,106,207,208,209,210, 311,312,313,314,315,415,416,417,418). I would like to create 2 new variables based on the site column.
-
if site=101,103,206,313,314 then lang=Chinese,site=415,416,315,418 then Lang=french, site=208,209,210 then lang=German, site=102,104,106,311,312 then lang=English.
-
if site=415,416,315,418,208,209,210 101,103,206,313,314 group=1, site=102,104,106,311,312 group=2
How to do this conditionally one by one in a loop/ any effective method in R, please suggest.
Aucun commentaire:
Enregistrer un commentaire