CoCalc Public Filesdm_addhealth_smasoodi.rmdOpen in with one click!
Author: sadaf masoodi
Views : 121

title: "Rmarkdown with code" author: "Sadaf Masood" date: "02/12/2020"

I am going to import the proper libraries and load the addhealth4 data, Also going to select variables for our research.

This command loads our data

load("~/Data/addhealth4.RData")

This command names our data

ls()

now we will load our packages so that we can use commands.

library(dplyr)
library(janitor)
load("~/Data/addhealth4.RData")

selection of Variables

  1. H4ED1 what is your high school graduation status?
  • Categorical Variable
mydata <- addhealth4 %>%
    select (H4ED1, H4ED2,H4EC2,H4ED4A)

next I will be cleaning the variables.

clean <- mydata %>%
    mutate(new_H4ED1 = recode(H4ED1,
                              "1" = "finished high school with diploma",
                              "2" = "earned a high school degree (GED)",
                              "3" = "earned a certificate of attendance or a certificate of completion",
                              "4" = "did not receive a high school diploma, equivalency degree (GED), or other                                               certificate",
                              "8" = "don’t know"))%>%
    mutate(new_H4ED2 = recode(H4ED2,
                              "1" = "8th grade less",
	                          "2" = "Some high school",
	                          "3" = "highschool graduate",
                              "4" = "some vocational/technical training (after Highschool)",
                              "5" = "completed vocational/technical training (after highschool)",
	                          "6" = "some college",
	                          "7" = "completed college bachelors degree",
	                          "8" = "some graduate school",
	                          "9" = "completed masters degree",
                              "10" = "some graduate training",
	                          "11" = "completed doctoral degree",
	                          "12" = "some post baccalaureate professional education"))

save(clean, file="~/Data/first_project.RData")