[1]In my dataset I have responses to a yes/no question, with a lot of missing values.
The column for the question looks something like this:
Question[1] yes[2] no[3] [4] yes[5] no[6]
In other words:
summary(Question)173yes160no155
where we have 173 missing values, 160 yes answers, and 155 no's.
When I look at levels in the factor, I get the following:
levels(Question)[1] " "[2] yes[3] no
I would like to drop the missing values (that is, level " ") (and have legitimate reasons to exclude missing values in this case).
However, is.na(Question) reports (implausibly) that there are no missing values, so I cannot easily exclude them.
I have tried dropping the level with missing values:
droplevels.factor(Question, exclude={" "}
but it results in a "NAs introduced by coercion" warning message.
What can I do to exclude the level with missing values? Please help. Thank you.
Edited with link to data file.
Best Answer
you can use scan
scan(text=Questions,what="character",quiet=TRUE)