0

I tried to conduct Chi-Squared test in R but I came upon an obstacle. In my data I have some observations which I would like to delete, because they aren't significant enough, specifically for this table I want to get rid of values such as "Don't know", "Refusal" and "No answer":

> TAB <- table(gender, health)
> TAB
        health
gender    Bad Don't know Fair Good No answer Refusal Very bad Very good
  Female  974          4 4021 6563         0       1      203      3587
  Male    688          8 3319 6407         1       1      146      3691

I want to delete observations which take these values from the whole data frame. I tried doing that by

> remove <- c("Refusal", "Don't know", "No answer")
> ess_data1 = ess_data[! health %in% remove, all()]

But in the result I still get responses such as before but with count equal to 0:

    health
gender    Bad Don't know Fair Good No answer Refusal Very bad Very good
  Female  974          0 4021 6563         0       0      203      3587
  Male    688          0 3319 6407         0       0      146      3691

Is there any simple way to filter this data frame to obtain table without these redundant observations and values?

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
czarq
  • 1
  • Can you provide full data for you example, see https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for help on reproducible example – Bulat Mar 06 '21 at 12:12
  • 2
    Try `droplevels(health)` – G5W Mar 06 '21 at 12:17

0 Answers0