This question already has an answer here:
- How to find mean for subset using R? 2 answers
- Finding the mean of a subset 1 answer
In R I am attempting to test the mean number of children someone with college education vs someone without college education has from the US census. However I learned there was a heavy skew in the data from age so I meant to restrict age to over 18. However once I would restrict both age and college education level functions would stop working on the data-set (the data set created looks normal). The functions still don't work but I have gotten closer by making the 18> a variable
eighteen<-ACS_2016_CO$NCHILD[ACS_2016_CO$AGE>17]
eighteen[ACS_2016_CO$EDUCD>6]
gives numeric data
eighteen[ACS_2016_CO$EDUCD<7]
gives numeric data
mean(eighteen[ACS_2016_CO$EDUCD<7])
gives N/A
I have tried with sum and length to attempt to cheese it but both functions too give N/A. Is there a quicker way to restrict both the age and education level at once or does anyone know the reason N/A keeps showing up? Thank-You!