I have a book on statistics (using R) showing the following:
> pima$diastolic [pima$diastolic = = 0] <- NA
> pima$glucose [pima$glucose == 0] <- NA
> pima$triceps [pima$triceps == 0] <- NA
> pima$insulin [pima$insulin == 0] <- NA
> pima$bmi [pima$bmi == 0] <- NA
Is there a way to do it in one line or more efficiently? I see there are functions such as with, apply, subset for doing similar stuff but could not figure out how to put them together...
Sample data (how do I read this in as a dataframe (like pythons stringio):
pregnant glucose diastolic triceps insulin bmi diabetes age test
1 6 148 72 35 0 33.6 0.627 50 positive
2 1 85 66 29 0 26.6 0.351 31 negative
3 8 183 64 0 0 23.3 0.672 32 positive
4 1 89 66 23 94 28.1 0.167 21 negative
5 0 137 40 35 168 43.1 2.288 33 positive
6 5 116 74 0 0 25.6 0.201 30 negative