── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.3 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.3 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(haven)library(rstatix)
Attaching package: 'rstatix'
The following object is masked from 'package:stats':
filter
library(naniar)library(pls)
Attaching package: 'pls'
The following object is masked from 'package:stats':
loadings
data <-read_sav("MomOff2011Sept1.sav")# subset of interest variables complete_case <- data %>%select(contains("stress") |contains("Delin")) %>%select(-"stress.r") %>%drop_na()
Missing Data
n_mis_col <- data %>%is.na() %>%colSums() %>%sort(decreasing =TRUE)perc_mis_col <-round(( n_mis_col /nrow(data) ) *100, 2)incomplete_case <- data %>%select(contains("stress") |contains("Delin")) %>%select(-"stress.r")vis_miss(incomplete_case)
# 16% of the data will be -Inf with log transform ggplot(data=complete_case, aes(x =`DelinOverall#8v`)) +geom_histogram(color ="white") +scale_x_log10()
Warning: Transformation introduced infinite values in continuous x-axis
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.