When creating a table my category "never" is counted as different categories

Screen Shot 2020-05-08 at 3.52.36 AM

Please help! I don't understand why my 'never' variable is counted twice. I want to find the invalid 'never' variable and delete it and am not sure how to do that as well.

Hey there!

Welcome to the forum. It always helps if you have some data we can access directly so we can provide code that will work on the problem at hand. Minimal reproducible examples are the best.

It immediately seems evident that the second never is in fact "never " with a space. A great way to select columns you want to keep is via dplyr:

library(tidyverse)
df <- iris %>% select(Sepal.Length, Species)

df

In this example, you can see I took the iris data and asked to pipe it into the select function to only return Sepal.Length and Species into my dataframe called df which has now excluded the other 3 columns.

Hope this helps?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

It could also help to use str_trim from the {stringr} package to trim off the extra white space from "never " responses, so that they categorize with the "never" group, rather than as a distinct group.

1 Like

Thank you so much I was so confused!

1 Like