HertieDataScience / SyllabusAndLectures

Hertie School of Governance Introduction to Collaborative Social Science Data Analysis
MIT License
37 stars 60 forks source link

Character Variable With Semicolon Into Factor Variable #69

Open KatrinHeger opened 8 years ago

KatrinHeger commented 8 years ago

Hi everyone,

I tried to recode a character variable into a factor variable, which worked fine for all but two entries. These two entries have the character "endorsement; alleged military" and I assume that I can't recode them becaus of the semicolon. Any ideas, anyone?

Thanks!!!!

wwiebke commented 8 years ago

We've used some individual codes for recoding variables. If you know what factor level you need to replace "endorsement; alleged military" you could maybe try something like this:

data$variable[data$variable=="endorsement; alleged military"] <- 3 (the number of the label you need)