R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Including Plots

You can also embed plots, for example:

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(haven)

data <- read_sav("/Users/limjiyun/Desktop/GBA Data/hn23_all.sav")

HN23 <- read_sav("/Users/limjiyun/Desktop/GBA Data/HN23_24RC.sav")

selected_independentdata <- data %>%
  select(ID, N_NA, N_SUGAR, N_TDF, N_SFA, N_FAT, N_MUFA, N_PUFA, N_N3, N_N6) 

head(data)
## # A tibble: 6 × 629
##   mod_d ID    ID_fam  year region town_t apt_t psu     sex   age age_month  incm
##   <chr> <chr> <chr>  <dbl>  <dbl>  <dbl> <dbl> <chr> <dbl> <dbl>     <dbl> <dbl>
## 1 2024… YA84… YA842…  2023      1      1     2 YA84      1    75        NA     3
## 2 2024… YA84… YA842…  2023      1      1     2 YA84      2    70        NA     3
## 3 2024… YA84… YA842…  2023      1      1     2 YA84      2    42        NA     2
## 4 2024… YA84… YA842…  2023      1      1     2 YA84      2     9        NA     2
## 5 2024… YA84… YA842…  2023      1      1     2 YA84      1    43        NA     4
## 6 2024… YA84… YA842…  2023      1      1     2 YA84      2    12        NA     4
## # ℹ 617 more variables: ho_incm <dbl>, incm5 <dbl>, ho_incm5 <dbl>, edu <dbl>,
## #   occp <dbl>, wt_hs <dbl>, wt_itvex <dbl>, wt_oe <dbl>, wt_ntr <dbl>,
## #   wt_tot <dbl>, wt_oent <dbl>, kstrata <dbl>, cfam <dbl>, genertn <dbl>,
## #   allownc <dbl>, house <dbl>, live_t <dbl>, ainc_unit1 <dbl>, ainc_1 <dbl>,
## #   ainc <dbl>, marri_1 <dbl>, marri_2 <dbl>, fam_rela <dbl>, tins <dbl>,
## #   npins <dbl>, ID_F <chr>, ID_M <chr>, D_1_1 <dbl>, D_2_1 <dbl>,
## #   D_2_wk <dbl>, DI1_dg <dbl>, DI1_ag <dbl>, DI1_pr <dbl>, DI1_pt <dbl>, …
rm(selected_Independentdata)
## Warning in rm(selected_Independentdata): object 'selected_Independentdata' not
## found
selected_Demographicdata <- data %>%
  select(age, sex, incm, incm5)

selected_Depressiondata <- data %>%
  select(BP5, BP7)

#5 summary 
library(dplyr)
str(selected_independentdata) 
## tibble [6,929 × 10] (S3: tbl_df/tbl/data.frame)
##  $ ID     : chr [1:6929] "YA84208301" "YA84208302" "YA84212402" "YA84212404" ...
##   ..- attr(*, "label")= chr "개인 아이디"
##   ..- attr(*, "format.spss")= chr "A30"
##  $ N_NA   : num [1:6929] 502 1924 5363 2849 6601 ...
##   ..- attr(*, "label")= chr "나트륨 섭취량(mg)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_SUGAR: num [1:6929] 48.1 47.6 83.4 46.1 108.1 ...
##   ..- attr(*, "label")= chr "당 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_TDF  : num [1:6929] 20.93 5.31 25.21 18.92 29.89 ...
##   ..- attr(*, "label")= chr "식이섬유 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_SFA  : num [1:6929] 9.22 18.14 23.93 24.66 18.28 ...
##   ..- attr(*, "label")= chr "포화지방산 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_FAT  : num [1:6929] 25.6 50.3 122.5 100.6 50.2 ...
##   ..- attr(*, "label")= chr "지방 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_MUFA : num [1:6929] 10.7 21.1 30.3 22.8 15.7 ...
##   ..- attr(*, "label")= chr "단일불포화지방산 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_PUFA : num [1:6929] 3.47 6.69 57.19 42.79 10.22 ...
##   ..- attr(*, "label")= chr "다가불포화지방산 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_N3   : num [1:6929] 0.479 0.716 5.948 4.525 1.297 ...
##   ..- attr(*, "label")= chr "n-3계 지방산 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
##  $ N_N6   : num [1:6929] 3 5.98 51.25 38.05 8.91 ...
##   ..- attr(*, "label")= chr "n-6계 지방산 섭취량(g)"
##   ..- attr(*, "format.spss")= chr "F10.2"
summary(selected_independentdata)
##       ID                 N_NA             N_SUGAR             N_TDF       
##  Length:6929        Min.   :   67.23   Min.   :  0.0049   Min.   :  0.00  
##  Class :character   1st Qu.: 1803.51   1st Qu.: 28.3758   1st Qu.: 14.50  
##  Mode  :character   Median : 2726.51   Median : 48.4619   Median : 21.16  
##                     Mean   : 3054.86   Mean   : 57.2811   Mean   : 23.68  
##                     3rd Qu.: 3860.76   3rd Qu.: 75.7269   3rd Qu.: 30.18  
##                     Max.   :18259.19   Max.   :401.7834   Max.   :125.96  
##                     NA's   :143        NA's   :143        NA's   :143     
##      N_SFA               N_FAT              N_MUFA             N_PUFA        
##  Min.   :  0.08363   Min.   :  0.3622   Min.   :  0.1035   Min.   :  0.1278  
##  1st Qu.:  7.25500   1st Qu.: 25.5544   1st Qu.:  7.4980   1st Qu.:  6.3077  
##  Median : 12.50075   Median : 40.6147   Median : 12.6343   Median :  9.9946  
##  Mean   : 15.45060   Mean   : 48.4085   Mean   : 15.7154   Mean   : 12.2028  
##  3rd Qu.: 19.80172   3rd Qu.: 61.6043   3rd Qu.: 20.0716   3rd Qu.: 15.4041  
##  Max.   :175.89339   Max.   :506.0316   Max.   :209.0964   Max.   :111.0514  
##  NA's   :143         NA's   :143        NA's   :143        NA's   :143       
##       N_N3               N_N6         
##  Min.   : 0.00106   Min.   :  0.1267  
##  1st Qu.: 0.78987   1st Qu.:  5.3029  
##  Median : 1.34625   Median :  8.4016  
##  Mean   : 1.82548   Mean   : 10.3358  
##  3rd Qu.: 2.25217   3rd Qu.: 13.0473  
##  Max.   :24.41155   Max.   :100.4820  
##  NA's   :143        NA's   :143
library(dplyr)
str(selected_Demographicdata) 
## tibble [6,929 × 4] (S3: tbl_df/tbl/data.frame)
##  $ age  : num [1:6929] 75 70 42 9 43 12 5 53 42 43 ...
##   ..- attr(*, "label")= chr "나이"
##   ..- attr(*, "format.spss")= chr "F3.0"
##  $ sex  : num [1:6929] 1 2 2 2 1 2 1 1 1 2 ...
##   ..- attr(*, "label")= chr "성별"
##   ..- attr(*, "format.spss")= chr "F1.0"
##  $ incm : num [1:6929] 3 3 2 2 4 4 4 4 2 2 ...
##   ..- attr(*, "label")= chr "소득4분위수(개인)"
##   ..- attr(*, "format.spss")= chr "F1.0"
##  $ incm5: num [1:6929] 4 4 2 2 5 5 5 5 2 2 ...
##   ..- attr(*, "label")= chr "소득5분위수(개인)"
##   ..- attr(*, "format.spss")= chr "F1.0"
summary(selected_Demographicdata)
##       age             sex             incm           incm5   
##  Min.   : 1.00   Min.   :1.000   Min.   :1.000   Min.   :1   
##  1st Qu.:31.00   1st Qu.:1.000   1st Qu.:2.000   1st Qu.:2   
##  Median :51.00   Median :2.000   Median :3.000   Median :3   
##  Mean   :47.41   Mean   :1.554   Mean   :2.501   Mean   :3   
##  3rd Qu.:65.00   3rd Qu.:2.000   3rd Qu.:4.000   3rd Qu.:4   
##  Max.   :80.00   Max.   :2.000   Max.   :4.000   Max.   :5   
##                                  NA's   :26      NA's   :26
library(dplyr)
str(selected_Depressiondata) 
## tibble [6,929 × 2] (S3: tbl_df/tbl/data.frame)
##  $ BP5: num [1:6929] 2 1 2 8 2 2 8 1 2 2 ...
##   ..- attr(*, "label")= chr "2주이상 연속 우울감 여부"
##   ..- attr(*, "format.spss")= chr "F1.0"
##  $ BP7: num [1:6929] 2 2 1 8 2 2 8 1 2 1 ...
##   ..- attr(*, "label")= chr "1년간 정신문제 상담"
##   ..- attr(*, "format.spss")= chr "F1.0"
summary(selected_Depressiondata)
##       BP5             BP7       
##  Min.   :1.000   Min.   :1.000  
##  1st Qu.:2.000   1st Qu.:2.000  
##  Median :2.000   Median :2.000  
##  Mean   :2.589   Mean   :2.649  
##  3rd Qu.:2.000   3rd Qu.:2.000  
##  Max.   :9.000   Max.   :9.000  
##  NA's   :1       NA's   :1

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.