I have a CSV from an online survey including numerical, single choice and multiple choice questions. The multiple choice questions are represented like this:
┌─────┬─────┬────┬─────┐
│ A │ B │ C │ D │
├─────┼─────┼────┼─────┤
│ "Y" │ NA │ NA │ NA │
│ NA │ "Y" │ NA │ "Y" │
│ NA │ NA │ NA │ NA │
│ "Y" │ "Y" │ NA │ NA │
└─────┴─────┴────┴─────┘
So an answer is either the character "Y" or null.
Now my question is if there is a solution which lets me easily make a histogram or something similar to visualize the frequency of each answer and use it in statistical testing in R.
Sorry if this is trivial but I don't have the experience and couldn't dig something up yet.
If your csv is read in as a dataframe, df then:
df2 <- !is.na(df)
nrows <- nrow(df2)
yes <- apply(df2, 2, sum)
percentyes <- 100 * yes / nrows
percentno = 100 - percentyes
barplot(percentyes)