Hi, I am confused why a new data set will not be created to put only the 5 variables I want in it?
nhanes.2014 which is the big data set to a smaller one nhanes.smaller?
Library package "RHANES" reads NHANES files into R-studio
library (package = "RNHANES")
Reassigned values to data set nhanes.2014
nhanes.2014 <- nhanes_load_data(file_name = "WHQMEC_H", year = "2013-2014",
demographics = TRUE)
#Check Summary
#Renaming a smaller data set
nhanes.little <- nhanes.2014 %>%
#Selecting "RIDAGEYR, RIAGENDR,WHQ030M, WHQ500, WHQ520)
select(RIDAGEYR, RIAGENDR, WHQ030M, WHQ500, WHQ520)%>%
Changing Age = numeric, and everything else to be factor
mutate(RIDAGEYR = as.numeric(RIDAGEYR)) %>%
mutate(RIAGENDR = as.factor(RIAGENDR)) %>%
WHQ030M:How do you consider your weight (Factor)
Removing "don't know" option choice
mutate(WHQ030M = as.factor(WHQ030M)) %>%
mutate(WHQ030M = na_if(x = WHQ030M, y = 9)) %>%
WHQ500: Trying to do about weight (Factor)
Removing Not trying to do anything about your weight (4), refused (7),
Do not know (9)
mutate(WHQ500 = as.factor(WHQ500)) %>%
mutate(WHQ500 = na_if(x = WHQ500, y = 7)) %>%
mutate(WHQ500 = na_if(x = WHQ500, y = 9)) %>%
WHQ520: How often tried to lose weight
Removing Refused (7), Do not know (9)
mutate(WHQ520 = as.factor(WHQ520)) %>%
mutate(WHQ520 = na_if(x = WHQ520, y = 7)) %>%
mutate(WHQ520 = na_if(x = WHQ520, y = 9)) %>%
mutate(RIAGENDR = recode_factor(RIAGENDR,
1
= "Male",
2
= "Female")) %>%
mutate(WHQ030M = recode_factor(WHQ030M,
1
= "fat or overweight",
2
= "too thin",
3
= "about the right weight"))%>%
mutate(WHQ500 = recode_factor(WHQ500,
1
= "lose weight",
2
= "gain Weight",
3
= "stay the same weight",
4
= "not trying to do anything about your weight" )) %>%
mutate(WHQ520 = recode_factor(WHQ520,
1
= "never",
2
= "somtimes",
3
= "a lot" )) %>%
drop_na() %>%
rename(gender = RIAGENDR) %>%
rename(age = RIDAGEYR) %>%
rename(body_image = WHQ030M) %>%
rename(percieved_weight = WHQ500) %>%
rename(self_inervention = WHQ520) %>%
summary(object = nhanes.little)