samedi 16 mai 2020

How do you integrate >= statements with numbers in ifelse package? Error in ifelse:

I have a dataframe with a responses for each row and several rows. My goal is to have % content in each district. I planned on having finding total content for each district and the total respondents of the study in each district.

This is the code I used:

jbnew <- jb %>%
   mutate(content = ifelse(jb$sum.contentcir > 3),1,0)%>%
   nrow(filter(jb))
group_by(jd,district) %>%
   summarise(Num.Totalrespondents =n(),
             Num.totalcontent = sum(content))%>%
   mutate(percent.totalcontent = Num.totalcontent/Num.Totalrespondents)

I keep getting this:

Error in ifelse(jb$sum.contentcir >= 3) : 
  argument "yes" is missing, with no default

My intention for this code, was to say that those who had a sum of 3 of more will then have the "content column" as "1"

Could you kindly help me solve this issue?

Aucun commentaire:

Enregistrer un commentaire