pkg_list <- c("tidyverse", "psych", "rcompanion", "knitr", "car", "afex", "ez",
"ggfortify", "Hmisc", "emmeans", "jtools", "apaTables", "dplyr")
# purrr::walk(pkg_list, require, quietly = TRUE, character.only = TRUE)
pacman::p_load(pkg_list, character.only = TRUE)
For this hands on practice, load the spi
data set from the psych
package.
data("spi", package = "psych")
# Write your code here!
eval
to TRUE
once you complete this exercise). Use either ifelse()
, case_when()
, or factor()
then make sure that your code appropriately changed each variable with str()
or class()
spi <- spi %>%
mutate(.,
sex_f = factor(),
health_f = factor(),
education_f = factor(),
smoke_f = factor(),
exer_f = factor()
)
# Write your code here!
str(spi)
describe()
or skim()
to describe the data by each categorical variable# Write your code here!
# Write your code here!
# Write your code here!
# Write your code here!
# Write your code here!
Note: For the following questions, make sure to not use any of categorical variables you created above (lm()
requires integer variables for the y
variable)
# Write code here
# Write code here
# Write code here
# Write code here
4b. Now a table of the golbal parameters
# Write code here
# Write code here
# Write code here
p1edu
, p2edu
and education
are the education levels at three time points. Let’s see if education and exercise interact to predict health. Are these two variables within-group or between-group factors?spi %>%
gather(key="edu_period", value= "edu", p1edu, p2edu,education) %>%
select("edu","edu_period","health", "exer") -> yourdataframe
# Write code here
# Write code here
4b. How do smoke and exercise affect wellness?
# Write code here