Why is my filter not working and how can I make it work?

Hello,

I am new to R, can someone please what is wrong with my code? I want to filter my result to only show people who have answered "no" but my result generate 0 rows. I also tried another code but it gives me 3 rows and not 1. Does it have anything to do with the fact that my data is stored as factors and not characters?

I also tried another code but gave me three rows, what am I doing wrong?
Thanks in advance,
Christine

brfss2013 %>% 
+   select(hivtst6) %>% 
+   str()

='data.frame': 491775 obs. of 1 variable:
$ hivtst6: Factor w/ 2 levels "Yes","No": 2 1 1 2 2 1 2 2 2 2 ...

MY CODE

brfss2013 %>% 
  filter(as.character(hivtst6) == "yes") %>% 
  group_by(hivtst6) %>% 
  summarise(count = n()) 
brfss2013 %>% 
  filter (hivtst6 != "yes") %>% 
  group_by(hivtst6) %>% 
  summarise(count = n()) ste code here

18

would it be because it is case sensitive i.e. Yes or yes ?

1 Like

hahaha YES. Thank you so so much. It is indeed case sensitive and works with "Yes"

You're welcome! :grinning: