Setup & Data import

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   4.0.0     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── 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(readxl)
library(knitr)
library(mosaic)
## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## 
## The following object is masked from 'package:Matrix':
## 
##     mean
## 
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## 
## The following object is masked from 'package:purrr':
## 
##     cross
## 
## The following object is masked from 'package:ggplot2':
## 
##     stat
## 
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## 
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
library(ggplot2)
library(supernova)
library(AICcmodavg)
sleep_exercise_info <- read_excel("midterm_sleep_exercise.xlsx", 
    sheet = "participant_info_midterm")
View(sleep_exercise_info)
sleep_exercise_data <- read_excel("midterm_sleep_exercise.xlsx", 
    sheet = "sleep_data_midterm")
View(sleep_exercise_data)
glimpse(sleep_exercise_info)
## Rows: 100
## Columns: 4
## $ ID             <chr> "P001", "P002", "P003", "P004", "P005", "P006", "P007",…
## $ Exercise_Group <chr> "NONE", "Nonee", "None", "None", "None", "None", "None"…
## $ Sex            <chr> "Male", "Malee", "Female", "Female", "Male", "Female", …
## $ Age            <dbl> 35, 57, 26, 29, 33, 33, 32, 30, 37, 28, 30, 20, 42, 31,…
glimpse(sleep_exercise_data)
## Rows: 100
## Columns: 4
## $ ID               <chr> "P001", "P002", "P003", "P004", "P005", "P006", "P007…
## $ Pre_Sleep        <chr> "zzz-5.8", "Sleep-6.6", NA, "SLEEP-7.2", "score-7.4",…
## $ Post_Sleep       <dbl> 4.7, 7.4, 6.2, 7.3, 7.4, 7.1, 6.7, 9.0, 5.1, 6.3, 6.2…
## $ Sleep_Efficiency <dbl> 81.6, 75.7, 82.9, 83.6, 83.5, 88.5, 83.6, 73.4, 88.2,…

We have both data sets and are now ready to clean and analye our data.

Merge and Base Cleaning

clean_exercise_group<- sleep_exercise_info %>% 
  mutate(Exercise_Group = case_when(
    Exercise_Group %in% c("cardio", "CARDIO", "C") ~ "Cardio",
    Exercise_Group %in% c("WEIGHTS", "WEIGHTSSS", "WEIGHTZ") ~ "Weights",
    Exercise_Group %in% c("CW", "C+W") ~ "Cardio+Weights",
    Exercise_Group %in% c("Nonee", "NONE", "N") ~ "None",
    TRUE ~ Exercise_Group
  ))
View(clean_exercise_group)
clean_sex_label <- sleep_exercise_info %>% 
  mutate(Sex = case_when(
    Sex %in% c("F", "Fem", "Femalee") ~ "Female",
    Sex %in% c("M", "MALE", "Mal", "Malee") ~ "Male",
    TRUE ~ Sex
  ))
View(clean_sex_label)
exercise_group_data <- merge(clean_exercise_group, clean_sex_label)
View(exercise_group_data)
clean_sleep_data<- merge(exercise_group_data, sleep_exercise_data)
View(clean_sleep_data)

I was able to clean up the data in the Exercise group and Sex column in the sleep_exercise_info data set. Now the words in those columns are standardized. I also merged both data sets together.

Create Derived Variables

clean_sleep_data <- clean_sleep_data %>%
  mutate(
    pre_sleep_num = as.numeric(gsub("[^0-9.]", "", Pre_Sleep))
  )
clean_sleep_data <- clean_sleep_data %>% 
  mutate(Sleep_Difference = clean_sleep_data$Post_Sleep - clean_sleep_data$pre_sleep_num)

clean_sleep_data <- clean_sleep_data %>%  
  mutate(
    AgeGroup2 = case_when(
      Age < 40 ~ "40",
      Age >= 40 ~ "40+"
    )
  )
clean_sleep_data %>%filter(is.na(Sleep_Difference))
##     ID Exercise_Group    Sex Age Pre_Sleep Post_Sleep Sleep_Efficiency
## 1 P003           None Female  26      <NA>        6.2             82.9
## 2 P014           None   Male  31      <NA>        7.2             92.0
## 3 P019           None   Male  28      <NA>        5.7             69.1
## 4 P023           None Female  42   sleep-5         NA             81.3
## 5 P037         Cardio   Male  35      <NA>        9.7             85.6
## 6 P095 Cardio+Weights Female  29 Sleep-5.7         NA             85.0
## 7 P099 Cardio+Weights   Male  28      <NA>        8.8             88.5
##   pre_sleep_num Sleep_Difference AgeGroup2
## 1            NA               NA        40
## 2            NA               NA        40
## 3            NA               NA        40
## 4           5.0               NA       40+
## 5            NA               NA        40
## 6           5.7               NA        40
## 7            NA               NA        40
clean_sleep_data %>% filter(!is.na(Sleep_Difference))
##      ID Exercise_Group    Sex Age Pre_Sleep Post_Sleep Sleep_Efficiency
## 1  P004           None Female  29 SLEEP-7.2        7.3             83.6
## 2  P005           None   Male  33 score-7.4        7.4             83.5
## 3  P006           None Female  33 Sleep-6.6        7.1             88.5
## 4  P007           None   Male  32   Sleep-6        6.7             83.6
## 5  P008           None Female  30   zzz-8.1        9.0             73.4
## 6  P009           None   Male  37 sleep-5.5        5.1             88.2
## 7  P010           None Female  28 sleep-5.7        6.3             80.4
## 8  P011           None Female  30   score-7        6.2             85.2
## 9  P012           None   Male  20 sleep-5.5        4.6             82.9
## 10 P013           None   Male  42   Sleep-8        7.6             74.0
## 11 P016           None   Male  26 SLEEP-7.8        8.2             71.7
## 12 P017           None Female  41   zzz-6.7        7.6             78.5
## 13 P018           None   Male  18 SLEEP-7.4        7.2             73.8
## 14 P021           None   Male  48   zzz-6.8        7.1             78.7
## 15 P024           None Female  39   score-6        5.6             76.6
## 16 P026         Cardio Female  34 score-5.2        6.7             84.5
## 17 P027         Cardio Female  28 sleep-6.6        7.8             75.9
## 18 P028         Cardio Female  29 SLEEP-5.6        6.3             79.0
## 19 P029         Cardio   Male  36   Sleep-6        6.3             87.6
## 20 P031         Cardio Female  42 Sleep-6.9        7.6             88.5
## 21 P032         Cardio Female  18 SLEEP-6.9        7.9             87.8
## 22 P033         Cardio Female  38   zzz-5.9        6.6             80.9
## 23 P034         Cardio Female  20 score-5.2        6.0             92.8
## 24 P035         Cardio   Male  30 SLEEP-6.7        8.0             86.4
## 25 P036         Cardio Female  19   zzz-5.4        5.7             88.0
## 26 P038         Cardio Female  34     zzz-7        8.1             79.6
## 27 P039         Cardio   Male  39 SLEEP-5.6        6.3             81.3
## 28 P040         Cardio Female  39     zzz-6        8.1             79.7
## 29 P042         Cardio Female  28 SLEEP-5.6        7.3             81.9
## 30 P043         Cardio Female  43   zzz-6.9        8.2             81.3
## 31 P044         Cardio Female  33   zzz-5.8        7.1             88.7
## 32 P046         Cardio   Male  30 SLEEP-7.1        8.5             95.0
## 33 P047         Cardio Female  42 SLEEP-5.8        7.0             85.5
## 34 P050         Cardio   Male  31   zzz-6.4        8.4            101.5
## 35 P076 Cardio+Weights   Male  37 sleep-5.7        6.5             83.9
## 36 P077 Cardio+Weights Female  37 score-5.9        7.3             92.4
## 37 P078 Cardio+Weights Female  24 score-6.6        7.2             74.5
## 38 P079 Cardio+Weights   Male  38 SLEEP-6.6        7.4             89.0
## 39 P080 Cardio+Weights   Male  42 Sleep-7.2        8.1             94.5
## 40 P081 Cardio+Weights Female  38   Sleep-8        8.9             74.5
## 41 P082 Cardio+Weights   Male  46 score-6.5        6.4             88.7
## 42 P083 Cardio+Weights Female  49 score-5.9        6.8             90.4
## 43 P084 Cardio+Weights Female  31   sleep-8        8.4             80.2
## 44 P085 Cardio+Weights   Male  33 score-6.2        6.9             89.9
## 45 P086 Cardio+Weights Female  46 SLEEP-6.2        7.4             83.1
## 46 P087 Cardio+Weights   Male  18 SLEEP-6.7        7.6             96.3
## 47 P088 Cardio+Weights   Male  34 score-7.5        8.9             81.2
## 48 P090 Cardio+Weights Female  41 Sleep-7.2        7.6             79.9
## 49 P091 Cardio+Weights   Male  46   zzz-7.3        7.9             87.5
## 50 P093 Cardio+Weights Female  40   Sleep-8        9.5             90.4
## 51 P094 Cardio+Weights   Male  35   zzz-6.1        7.2             84.4
## 52 P097 Cardio+Weights   Male  24 SLEEP-4.4        4.7             88.9
## 53 P098 Cardio+Weights Female  35 score-5.9        6.9             92.6
## 54 P100 Cardio+Weights   Male  32   zzz-6.5        7.3             84.2
##    pre_sleep_num Sleep_Difference AgeGroup2
## 1            7.2              0.1        40
## 2            7.4              0.0        40
## 3            6.6              0.5        40
## 4            6.0              0.7        40
## 5            8.1              0.9        40
## 6            5.5             -0.4        40
## 7            5.7              0.6        40
## 8            7.0             -0.8        40
## 9            5.5             -0.9        40
## 10           8.0             -0.4       40+
## 11           7.8              0.4        40
## 12           6.7              0.9       40+
## 13           7.4             -0.2        40
## 14           6.8              0.3       40+
## 15           6.0             -0.4        40
## 16           5.2              1.5        40
## 17           6.6              1.2        40
## 18           5.6              0.7        40
## 19           6.0              0.3        40
## 20           6.9              0.7       40+
## 21           6.9              1.0        40
## 22           5.9              0.7        40
## 23           5.2              0.8        40
## 24           6.7              1.3        40
## 25           5.4              0.3        40
## 26           7.0              1.1        40
## 27           5.6              0.7        40
## 28           6.0              2.1        40
## 29           5.6              1.7        40
## 30           6.9              1.3       40+
## 31           5.8              1.3        40
## 32           7.1              1.4        40
## 33           5.8              1.2       40+
## 34           6.4              2.0        40
## 35           5.7              0.8        40
## 36           5.9              1.4        40
## 37           6.6              0.6        40
## 38           6.6              0.8        40
## 39           7.2              0.9       40+
## 40           8.0              0.9        40
## 41           6.5             -0.1       40+
## 42           5.9              0.9       40+
## 43           8.0              0.4        40
## 44           6.2              0.7        40
## 45           6.2              1.2       40+
## 46           6.7              0.9        40
## 47           7.5              1.4        40
## 48           7.2              0.4       40+
## 49           7.3              0.6       40+
## 50           8.0              1.5       40+
## 51           6.1              1.1        40
## 52           4.4              0.3        40
## 53           5.9              1.0        40
## 54           6.5              0.8        40

I created a new column and called it pre_sleep_num to make the Pre_Sleep column just numeric, without any of the characters. After making it numeric, I was able to create a derived variable called sleep_difference which was the scores from post_sleep minus the scores from pre_sleep. I also created a variable called Age_Group_ which conveyed whether participants were either 40 years old or younger, and 40+ years old. I also ran the is.na function to drop the rows in the Sleep_difference column

Descriptive Statistics

favstats(clean_sleep_data$Sleep_Difference)
##   min  Q1 median    Q3 max      mean        sd  n missing
##  -0.9 0.4    0.8 1.175 2.1 0.7240741 0.6398512 54       7
favstats(clean_sleep_data$Sleep_Efficiency)
##   min   Q1 median   Q3   max     mean       sd  n missing
##  69.1 80.2   84.2 88.5 101.5 84.25246 6.495886 61       0
clean_sleep_data %>% 
  group_by(Exercise_Group) %>%
  summarise(
    mean_sleep_difference = mean(Sleep_Difference, na.rm = TRUE)
  )
## # A tibble: 3 × 2
##   Exercise_Group mean_sleep_difference
##   <chr>                          <dbl>
## 1 Cardio                        1.12  
## 2 Cardio+Weights                0.825 
## 3 None                          0.0867
clean_sleep_data %>% 
  group_by(Exercise_Group) %>% 
  summarise(
    mean_sleep_efficiency = mean(Sleep_Efficiency, na.rm = TRUE)
  )
## # A tibble: 3 × 2
##   Exercise_Group mean_sleep_efficiency
##   <chr>                          <dbl>
## 1 Cardio                          85.6
## 2 Cardio+Weights                  86.4
## 3 None                            80.4
kable(clean_sleep_data)
ID Exercise_Group Sex Age Pre_Sleep Post_Sleep Sleep_Efficiency pre_sleep_num Sleep_Difference AgeGroup2
P003 None Female 26 NA 6.2 82.9 NA NA 40
P004 None Female 29 SLEEP-7.2 7.3 83.6 7.2 0.1 40
P005 None Male 33 score-7.4 7.4 83.5 7.4 0.0 40
P006 None Female 33 Sleep-6.6 7.1 88.5 6.6 0.5 40
P007 None Male 32 Sleep-6 6.7 83.6 6.0 0.7 40
P008 None Female 30 zzz-8.1 9.0 73.4 8.1 0.9 40
P009 None Male 37 sleep-5.5 5.1 88.2 5.5 -0.4 40
P010 None Female 28 sleep-5.7 6.3 80.4 5.7 0.6 40
P011 None Female 30 score-7 6.2 85.2 7.0 -0.8 40
P012 None Male 20 sleep-5.5 4.6 82.9 5.5 -0.9 40
P013 None Male 42 Sleep-8 7.6 74.0 8.0 -0.4 40+
P014 None Male 31 NA 7.2 92.0 NA NA 40
P016 None Male 26 SLEEP-7.8 8.2 71.7 7.8 0.4 40
P017 None Female 41 zzz-6.7 7.6 78.5 6.7 0.9 40+
P018 None Male 18 SLEEP-7.4 7.2 73.8 7.4 -0.2 40
P019 None Male 28 NA 5.7 69.1 NA NA 40
P021 None Male 48 zzz-6.8 7.1 78.7 6.8 0.3 40+
P023 None Female 42 sleep-5 NA 81.3 5.0 NA 40+
P024 None Female 39 score-6 5.6 76.6 6.0 -0.4 40
P026 Cardio Female 34 score-5.2 6.7 84.5 5.2 1.5 40
P027 Cardio Female 28 sleep-6.6 7.8 75.9 6.6 1.2 40
P028 Cardio Female 29 SLEEP-5.6 6.3 79.0 5.6 0.7 40
P029 Cardio Male 36 Sleep-6 6.3 87.6 6.0 0.3 40
P031 Cardio Female 42 Sleep-6.9 7.6 88.5 6.9 0.7 40+
P032 Cardio Female 18 SLEEP-6.9 7.9 87.8 6.9 1.0 40
P033 Cardio Female 38 zzz-5.9 6.6 80.9 5.9 0.7 40
P034 Cardio Female 20 score-5.2 6.0 92.8 5.2 0.8 40
P035 Cardio Male 30 SLEEP-6.7 8.0 86.4 6.7 1.3 40
P036 Cardio Female 19 zzz-5.4 5.7 88.0 5.4 0.3 40
P037 Cardio Male 35 NA 9.7 85.6 NA NA 40
P038 Cardio Female 34 zzz-7 8.1 79.6 7.0 1.1 40
P039 Cardio Male 39 SLEEP-5.6 6.3 81.3 5.6 0.7 40
P040 Cardio Female 39 zzz-6 8.1 79.7 6.0 2.1 40
P042 Cardio Female 28 SLEEP-5.6 7.3 81.9 5.6 1.7 40
P043 Cardio Female 43 zzz-6.9 8.2 81.3 6.9 1.3 40+
P044 Cardio Female 33 zzz-5.8 7.1 88.7 5.8 1.3 40
P046 Cardio Male 30 SLEEP-7.1 8.5 95.0 7.1 1.4 40
P047 Cardio Female 42 SLEEP-5.8 7.0 85.5 5.8 1.2 40+
P050 Cardio Male 31 zzz-6.4 8.4 101.5 6.4 2.0 40
P076 Cardio+Weights Male 37 sleep-5.7 6.5 83.9 5.7 0.8 40
P077 Cardio+Weights Female 37 score-5.9 7.3 92.4 5.9 1.4 40
P078 Cardio+Weights Female 24 score-6.6 7.2 74.5 6.6 0.6 40
P079 Cardio+Weights Male 38 SLEEP-6.6 7.4 89.0 6.6 0.8 40
P080 Cardio+Weights Male 42 Sleep-7.2 8.1 94.5 7.2 0.9 40+
P081 Cardio+Weights Female 38 Sleep-8 8.9 74.5 8.0 0.9 40
P082 Cardio+Weights Male 46 score-6.5 6.4 88.7 6.5 -0.1 40+
P083 Cardio+Weights Female 49 score-5.9 6.8 90.4 5.9 0.9 40+
P084 Cardio+Weights Female 31 sleep-8 8.4 80.2 8.0 0.4 40
P085 Cardio+Weights Male 33 score-6.2 6.9 89.9 6.2 0.7 40
P086 Cardio+Weights Female 46 SLEEP-6.2 7.4 83.1 6.2 1.2 40+
P087 Cardio+Weights Male 18 SLEEP-6.7 7.6 96.3 6.7 0.9 40
P088 Cardio+Weights Male 34 score-7.5 8.9 81.2 7.5 1.4 40
P090 Cardio+Weights Female 41 Sleep-7.2 7.6 79.9 7.2 0.4 40+
P091 Cardio+Weights Male 46 zzz-7.3 7.9 87.5 7.3 0.6 40+
P093 Cardio+Weights Female 40 Sleep-8 9.5 90.4 8.0 1.5 40+
P094 Cardio+Weights Male 35 zzz-6.1 7.2 84.4 6.1 1.1 40
P095 Cardio+Weights Female 29 Sleep-5.7 NA 85.0 5.7 NA 40
P097 Cardio+Weights Male 24 SLEEP-4.4 4.7 88.9 4.4 0.3 40
P098 Cardio+Weights Female 35 score-5.9 6.9 92.6 5.9 1.0 40
P099 Cardio+Weights Male 28 NA 8.8 88.5 NA NA 40
P100 Cardio+Weights Male 32 zzz-6.5 7.3 84.2 6.5 0.8 40

I did some descriptive statistics to look at the mean, min, max, and sd for Sleep_difference and Sleep_efficiency. I also looked at the group means by Exercise Group for Sleep_difference and Sleep_efficiency.

Visualization

ggplot(clean_sleep_data, aes(x = Exercise_Group, y = Sleep_Difference)) + 
  geom_boxplot() + 
  labs(
    title = "Relationship between Sleep Difference and Exercise Group", 
    x = "Exercise Group",
    y = "Sleep Difference"
  ) +
  theme_minimal()
## Warning: Removed 7 rows containing non-finite outside the scale range
## (`stat_boxplot()`).

ggplot(clean_sleep_data, aes(x = Exercise_Group, y = Sleep_Efficiency)) + 
  geom_boxplot() + 
  labs(
    title = "Relationship between Sleep Efficiency and Exercise Group",
    x = "Exercise Group",
    y = "Sleep Efficiency"
  )

theme_minimal()
## <theme> List of 144
##  $ line                            : <ggplot2::element_line>
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ lineend      : chr "butt"
##   ..@ linejoin     : chr "round"
##   ..@ arrow        : logi FALSE
##   ..@ arrow.fill   : chr "black"
##   ..@ inherit.blank: logi TRUE
##  $ rect                            : <ggplot2::element_rect>
##   ..@ fill         : chr "white"
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ linejoin     : chr "round"
##   ..@ inherit.blank: logi TRUE
##  $ text                            : <ggplot2::element_text>
##   ..@ family       : chr ""
##   ..@ face         : chr "plain"
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : chr "black"
##   ..@ size         : num 11
##   ..@ hjust        : num 0.5
##   ..@ vjust        : num 0.5
##   ..@ angle        : num 0
##   ..@ lineheight   : num 0.9
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 0
##   ..@ debug        : logi FALSE
##   ..@ inherit.blank: logi TRUE
##  $ title                           : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ point                           : <ggplot2::element_point>
##   ..@ colour       : chr "black"
##   ..@ shape        : num 19
##   ..@ size         : num 1.5
##   ..@ fill         : chr "white"
##   ..@ stroke       : num 0.5
##   ..@ inherit.blank: logi TRUE
##  $ polygon                         : <ggplot2::element_polygon>
##   ..@ fill         : chr "white"
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ linejoin     : chr "round"
##   ..@ inherit.blank: logi TRUE
##  $ geom                            : <ggplot2::element_geom>
##   ..@ ink        : chr "black"
##   ..@ paper      : chr "white"
##   ..@ accent     : chr "#3366FF"
##   ..@ linewidth  : num 0.5
##   ..@ borderwidth: num 0.5
##   ..@ linetype   : int 1
##   ..@ bordertype : int 1
##   ..@ family     : chr ""
##   ..@ fontsize   : num 3.87
##   ..@ pointsize  : num 1.5
##   ..@ pointshape : num 19
##   ..@ colour     : NULL
##   ..@ fill       : NULL
##  $ spacing                         : 'simpleUnit' num 5.5points
##   ..- attr(*, "unit")= int 8
##  $ margins                         : <ggplot2::margin> num [1:4] 5.5 5.5 5.5 5.5
##  $ aspect.ratio                    : NULL
##  $ axis.title                      : NULL
##  $ axis.title.x                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 2.75 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.x.top                : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 0
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 2.75 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.x.bottom             : NULL
##  $ axis.title.y                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : num 90
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.75 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.y.left               : NULL
##  $ axis.title.y.right              : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : num -90
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 2.75
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text                       : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : chr "#4D4D4DFF"
##   ..@ size         : 'rel' num 0.8
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 2.2 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x.top                 : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 4.95 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x.bottom              : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 4.95 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 1
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.2 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y.left                : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 4.95 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y.right               : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 4.95
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.theta                 : NULL
##  $ axis.text.r                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 0.5
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.2 0 2.2
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.ticks                      : <ggplot2::element_blank>
##  $ axis.ticks.x                    : NULL
##  $ axis.ticks.x.top                : NULL
##  $ axis.ticks.x.bottom             : NULL
##  $ axis.ticks.y                    : NULL
##  $ axis.ticks.y.left               : NULL
##  $ axis.ticks.y.right              : NULL
##  $ axis.ticks.theta                : NULL
##  $ axis.ticks.r                    : NULL
##  $ axis.minor.ticks.x.top          : NULL
##  $ axis.minor.ticks.x.bottom       : NULL
##  $ axis.minor.ticks.y.left         : NULL
##  $ axis.minor.ticks.y.right        : NULL
##  $ axis.minor.ticks.theta          : NULL
##  $ axis.minor.ticks.r              : NULL
##  $ axis.ticks.length               : 'rel' num 0.5
##  $ axis.ticks.length.x             : NULL
##  $ axis.ticks.length.x.top         : NULL
##  $ axis.ticks.length.x.bottom      : NULL
##  $ axis.ticks.length.y             : NULL
##  $ axis.ticks.length.y.left        : NULL
##  $ axis.ticks.length.y.right       : NULL
##  $ axis.ticks.length.theta         : NULL
##  $ axis.ticks.length.r             : NULL
##  $ axis.minor.ticks.length         : 'rel' num 0.75
##  $ axis.minor.ticks.length.x       : NULL
##  $ axis.minor.ticks.length.x.top   : NULL
##  $ axis.minor.ticks.length.x.bottom: NULL
##  $ axis.minor.ticks.length.y       : NULL
##  $ axis.minor.ticks.length.y.left  : NULL
##  $ axis.minor.ticks.length.y.right : NULL
##  $ axis.minor.ticks.length.theta   : NULL
##  $ axis.minor.ticks.length.r       : NULL
##  $ axis.line                       : <ggplot2::element_blank>
##  $ axis.line.x                     : NULL
##  $ axis.line.x.top                 : NULL
##  $ axis.line.x.bottom              : NULL
##  $ axis.line.y                     : NULL
##  $ axis.line.y.left                : NULL
##  $ axis.line.y.right               : NULL
##  $ axis.line.theta                 : NULL
##  $ axis.line.r                     : NULL
##  $ legend.background               : <ggplot2::element_blank>
##  $ legend.margin                   : NULL
##  $ legend.spacing                  : 'rel' num 2
##  $ legend.spacing.x                : NULL
##  $ legend.spacing.y                : NULL
##  $ legend.key                      : <ggplot2::element_blank>
##  $ legend.key.size                 : 'simpleUnit' num 1.2lines
##   ..- attr(*, "unit")= int 3
##  $ legend.key.height               : NULL
##  $ legend.key.width                : NULL
##  $ legend.key.spacing              : NULL
##  $ legend.key.spacing.x            : NULL
##  $ legend.key.spacing.y            : NULL
##  $ legend.key.justification        : NULL
##  $ legend.frame                    : NULL
##  $ legend.ticks                    : NULL
##  $ legend.ticks.length             : 'rel' num 0.2
##  $ legend.axis.line                : NULL
##  $ legend.text                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : 'rel' num 0.8
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ legend.text.position            : NULL
##  $ legend.title                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 0
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ legend.title.position           : NULL
##  $ legend.position                 : chr "right"
##  $ legend.position.inside          : NULL
##  $ legend.direction                : NULL
##  $ legend.byrow                    : NULL
##  $ legend.justification            : chr "center"
##  $ legend.justification.top        : NULL
##  $ legend.justification.bottom     : NULL
##  $ legend.justification.left       : NULL
##  $ legend.justification.right      : NULL
##  $ legend.justification.inside     : NULL
##   [list output truncated]
##  @ complete: logi TRUE
##  @ validate: logi TRUE
ggplot(clean_sleep_data, aes(x = Sleep_Difference, y = Sleep_Efficiency)) + 
  geom_point() + 
  geom_smooth(method="lm") +
  labs(
    title = "Relationship between Sleep Difference and Efficiency",
    x = "Sleep Difference",
    y = "Sleep Efficiency"
  )
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 7 rows containing non-finite outside the scale range
## (`stat_smooth()`).
## Warning: Removed 7 rows containing missing values or values outside the scale range
## (`geom_point()`).

theme_minimal()
## <theme> List of 144
##  $ line                            : <ggplot2::element_line>
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ lineend      : chr "butt"
##   ..@ linejoin     : chr "round"
##   ..@ arrow        : logi FALSE
##   ..@ arrow.fill   : chr "black"
##   ..@ inherit.blank: logi TRUE
##  $ rect                            : <ggplot2::element_rect>
##   ..@ fill         : chr "white"
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ linejoin     : chr "round"
##   ..@ inherit.blank: logi TRUE
##  $ text                            : <ggplot2::element_text>
##   ..@ family       : chr ""
##   ..@ face         : chr "plain"
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : chr "black"
##   ..@ size         : num 11
##   ..@ hjust        : num 0.5
##   ..@ vjust        : num 0.5
##   ..@ angle        : num 0
##   ..@ lineheight   : num 0.9
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 0
##   ..@ debug        : logi FALSE
##   ..@ inherit.blank: logi TRUE
##  $ title                           : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ point                           : <ggplot2::element_point>
##   ..@ colour       : chr "black"
##   ..@ shape        : num 19
##   ..@ size         : num 1.5
##   ..@ fill         : chr "white"
##   ..@ stroke       : num 0.5
##   ..@ inherit.blank: logi TRUE
##  $ polygon                         : <ggplot2::element_polygon>
##   ..@ fill         : chr "white"
##   ..@ colour       : chr "black"
##   ..@ linewidth    : num 0.5
##   ..@ linetype     : num 1
##   ..@ linejoin     : chr "round"
##   ..@ inherit.blank: logi TRUE
##  $ geom                            : <ggplot2::element_geom>
##   ..@ ink        : chr "black"
##   ..@ paper      : chr "white"
##   ..@ accent     : chr "#3366FF"
##   ..@ linewidth  : num 0.5
##   ..@ borderwidth: num 0.5
##   ..@ linetype   : int 1
##   ..@ bordertype : int 1
##   ..@ family     : chr ""
##   ..@ fontsize   : num 3.87
##   ..@ pointsize  : num 1.5
##   ..@ pointshape : num 19
##   ..@ colour     : NULL
##   ..@ fill       : NULL
##  $ spacing                         : 'simpleUnit' num 5.5points
##   ..- attr(*, "unit")= int 8
##  $ margins                         : <ggplot2::margin> num [1:4] 5.5 5.5 5.5 5.5
##  $ aspect.ratio                    : NULL
##  $ axis.title                      : NULL
##  $ axis.title.x                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 2.75 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.x.top                : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 0
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 2.75 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.x.bottom             : NULL
##  $ axis.title.y                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : num 90
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.75 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.title.y.left               : NULL
##  $ axis.title.y.right              : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : num -90
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 2.75
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text                       : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : chr "#4D4D4DFF"
##   ..@ size         : 'rel' num 0.8
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : num 1
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 2.2 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x.top                 : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 4.95 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.x.bottom              : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 4.95 0 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 1
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.2 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y.left                : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 4.95 0 0
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.y.right               : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 0 0 4.95
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.text.theta                 : NULL
##  $ axis.text.r                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 0.5
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : <ggplot2::margin> num [1:4] 0 2.2 0 2.2
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ axis.ticks                      : <ggplot2::element_blank>
##  $ axis.ticks.x                    : NULL
##  $ axis.ticks.x.top                : NULL
##  $ axis.ticks.x.bottom             : NULL
##  $ axis.ticks.y                    : NULL
##  $ axis.ticks.y.left               : NULL
##  $ axis.ticks.y.right              : NULL
##  $ axis.ticks.theta                : NULL
##  $ axis.ticks.r                    : NULL
##  $ axis.minor.ticks.x.top          : NULL
##  $ axis.minor.ticks.x.bottom       : NULL
##  $ axis.minor.ticks.y.left         : NULL
##  $ axis.minor.ticks.y.right        : NULL
##  $ axis.minor.ticks.theta          : NULL
##  $ axis.minor.ticks.r              : NULL
##  $ axis.ticks.length               : 'rel' num 0.5
##  $ axis.ticks.length.x             : NULL
##  $ axis.ticks.length.x.top         : NULL
##  $ axis.ticks.length.x.bottom      : NULL
##  $ axis.ticks.length.y             : NULL
##  $ axis.ticks.length.y.left        : NULL
##  $ axis.ticks.length.y.right       : NULL
##  $ axis.ticks.length.theta         : NULL
##  $ axis.ticks.length.r             : NULL
##  $ axis.minor.ticks.length         : 'rel' num 0.75
##  $ axis.minor.ticks.length.x       : NULL
##  $ axis.minor.ticks.length.x.top   : NULL
##  $ axis.minor.ticks.length.x.bottom: NULL
##  $ axis.minor.ticks.length.y       : NULL
##  $ axis.minor.ticks.length.y.left  : NULL
##  $ axis.minor.ticks.length.y.right : NULL
##  $ axis.minor.ticks.length.theta   : NULL
##  $ axis.minor.ticks.length.r       : NULL
##  $ axis.line                       : <ggplot2::element_blank>
##  $ axis.line.x                     : NULL
##  $ axis.line.x.top                 : NULL
##  $ axis.line.x.bottom              : NULL
##  $ axis.line.y                     : NULL
##  $ axis.line.y.left                : NULL
##  $ axis.line.y.right               : NULL
##  $ axis.line.theta                 : NULL
##  $ axis.line.r                     : NULL
##  $ legend.background               : <ggplot2::element_blank>
##  $ legend.margin                   : NULL
##  $ legend.spacing                  : 'rel' num 2
##  $ legend.spacing.x                : NULL
##  $ legend.spacing.y                : NULL
##  $ legend.key                      : <ggplot2::element_blank>
##  $ legend.key.size                 : 'simpleUnit' num 1.2lines
##   ..- attr(*, "unit")= int 3
##  $ legend.key.height               : NULL
##  $ legend.key.width                : NULL
##  $ legend.key.spacing              : NULL
##  $ legend.key.spacing.x            : NULL
##  $ legend.key.spacing.y            : NULL
##  $ legend.key.justification        : NULL
##  $ legend.frame                    : NULL
##  $ legend.ticks                    : NULL
##  $ legend.ticks.length             : 'rel' num 0.2
##  $ legend.axis.line                : NULL
##  $ legend.text                     : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : 'rel' num 0.8
##   ..@ hjust        : NULL
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ legend.text.position            : NULL
##  $ legend.title                    : <ggplot2::element_text>
##   ..@ family       : NULL
##   ..@ face         : NULL
##   ..@ italic       : chr NA
##   ..@ fontweight   : num NA
##   ..@ fontwidth    : num NA
##   ..@ colour       : NULL
##   ..@ size         : NULL
##   ..@ hjust        : num 0
##   ..@ vjust        : NULL
##   ..@ angle        : NULL
##   ..@ lineheight   : NULL
##   ..@ margin       : NULL
##   ..@ debug        : NULL
##   ..@ inherit.blank: logi TRUE
##  $ legend.title.position           : NULL
##  $ legend.position                 : chr "right"
##  $ legend.position.inside          : NULL
##  $ legend.direction                : NULL
##  $ legend.byrow                    : NULL
##  $ legend.justification            : chr "center"
##  $ legend.justification.top        : NULL
##  $ legend.justification.bottom     : NULL
##  $ legend.justification.left       : NULL
##  $ legend.justification.right      : NULL
##  $ legend.justification.inside     : NULL
##   [list output truncated]
##  @ complete: logi TRUE
##  @ validate: logi TRUE

I created 3 plots, the first 2 were box plots that showed the relationship between Sleep_difference and Exercise group, and Sleep_efficiceny and Exercise group. The last one was a scatterplot to look at the relationship between Sleep_efficiency and Sleep_difference.

T-Tests

ind_t_test_sex<- t.test(Sleep_Difference ~ Sex, data = clean_sleep_data)
ind_t_test_sex
## 
##  Welch Two Sample t-test
## 
## data:  Sleep_Difference by Sex
## t = 1.7108, df = 46.409, p-value = 0.0938
## alternative hypothesis: true difference in means between group Female and group Male is not equal to 0
## 95 percent confidence interval:
##  -0.05259837  0.64926503
## sample estimates:
## mean in group Female   mean in group Male 
##            0.8566667            0.5583333

The mean for the female group is 0.8566667, and the mean for the male group is 0.5583333. The p-value is 0.0938, making the differences not statistically significant.

ind_t_test_age<- t.test(Sleep_Difference ~ AgeGroup2, data = clean_sleep_data)
ind_t_test_age
## 
##  Welch Two Sample t-test
## 
## data:  Sleep_Difference by AgeGroup2
## t = 0.0070374, df = 24.033, p-value = 0.9944
## alternative hypothesis: true difference in means between group 40 and group 40+ is not equal to 0
## 95 percent confidence interval:
##  -0.3838214  0.3864481
## sample estimates:
##  mean in group 40 mean in group 40+ 
##         0.7243902         0.7230769

The mean for age group 40 is 0.7243902, and the mean for group 40+ is 0.7230769. The p-value is 0.9944, making the difference not statistically significant.

I ran independent t-tests for Sleep_difference and sex, and another one for Sleep_difference by AgeGroup2.

Anovas + Post-Hocs

anova_sleep_difference<- aov(Sleep_Difference ~ Exercise_Group, data = clean_sleep_data)
summary(anova_sleep_difference)
##                Df Sum Sq Mean Sq F value   Pr(>F)    
## Exercise_Group  2  9.292   4.646    19.1 6.44e-07 ***
## Residuals      51 12.406   0.243                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 7 observations deleted due to missingness
supernova(anova_sleep_difference)
## Refitting to remove 7 cases with missing value(s)
## ℹ aov(formula = Sleep_Difference ~ Exercise_Group, data = listwise_delete(clean_sleep_data, 
##     c("Sleep_Difference", "Exercise_Group")))
##  Analysis of Variance Table (Type III SS)
##  Model: Sleep_Difference ~ Exercise_Group
## 
##                              SS df    MS      F   PRE     p
##  ----- --------------- | ------ -- ----- ------ ----- -----
##  Model (error reduced) |  9.292  2 4.646 19.099 .4282 .0000
##  Error (from model)    | 12.406 51 0.243                   
##  ----- --------------- | ------ -- ----- ------ ----- -----
##  Total (empty model)   | 21.699 53 0.409
TukeyHSD(anova_sleep_difference)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Sleep_Difference ~ Exercise_Group, data = clean_sleep_data)
## 
## $Exercise_Group
##                             diff        lwr         upr     p adj
## Cardio+Weights-Cardio -0.2960526 -0.6774802  0.08537496 0.1567301
## None-Cardio           -1.0343860 -1.4456196 -0.62315233 0.0000005
## None-Cardio+Weights   -0.7383333 -1.1450060 -0.33166066 0.0001710
plot(TukeyHSD(anova_sleep_difference))

The F-value is 19.1, the df are 2 and 51, the p-value is .0000, the PRE is 42.82%. Looking at the adjusted p-values, None-Cardio and None-Cardio+Weights are the 2 groups that are statistically significant.

anova_sleep_efficiency<- aov(Sleep_Efficiency ~ Exercise_Group, data = clean_sleep_data)
summary(anova_sleep_efficiency)
##                Df Sum Sq Mean Sq F value  Pr(>F)   
## Exercise_Group  2  412.7  206.36   5.648 0.00574 **
## Residuals      58 2119.1   36.54                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
supernova(anova_sleep_efficiency)
##  Analysis of Variance Table (Type III SS)
##  Model: Sleep_Efficiency ~ Exercise_Group
## 
##                                SS df      MS     F   PRE     p
##  ----- --------------- | -------- -- ------- ----- ----- -----
##  Model (error reduced) |  412.718  2 206.359 5.648 .1630 .0057
##  Error (from model)    | 2119.074 58  36.536                  
##  ----- --------------- | -------- -- ------- ----- ----- -----
##  Total (empty model)   | 2531.792 60  42.197
TukeyHSD(anova_sleep_efficiency)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = Sleep_Efficiency ~ Exercise_Group, data = clean_sleep_data)
## 
## $Exercise_Group
##                             diff        lwr       upr     p adj
## Cardio+Weights-Cardio  0.7886364  -3.703252  5.280525 0.9065424
## None-Cardio           -5.1592105  -9.816907 -0.501514 0.0265716
## None-Cardio+Weights   -5.9478469 -10.501233 -1.394461 0.0073440
plot(TukeyHSD(anova_sleep_efficiency))

The F-value is 5.648, the df are 2 and 58, the p-value is 0.0057, the PRE is 16.30%. Looking at the adjusted p values, None-Cardio and None-Cardio+Weights are the 2 statistically significant groups.

I ran 2 ANOVAs, one for Sleep_difference and Exercise group, and the other for Sleep_efficiency and Exercise group. I also ran a Tukey post-hoc test for both ANOVAs.

Synthesis & Reccomendation

Considering both outcomes (Sleep Difference and Sleep Efficiency) of the anova and post-hoc tests, I would recommend cardio and weights as the exercise regimen to improve overall sleep. The reason for this is because in both the post-hoc tests we can see that cardio+weights-cardio has the smallest difference compared to the other 2 combinations in both tests. Although in the sleep efficiency ~ exercise group post-hoc test the difference between cardio+weights and none is the largest out of the 3 combinations (-5.9478469), it looks like ‘None’ is causing the difference to be large, and not cardio+weight. In the sleep difference ~ exercise group post-hoc test, none - cardio have the largest negative difference out of the the 3 combinations (-1.0343860), with none - cardio+weights having the second largest (-0.7383333), and cardio+weights - cardio having the smallest difference (-0.2960526), conveying that cardio+weight must be the exercise regimen that helps to improve overall sleep. We could also see the differences and their sizes in the plot of the Tukey post-hoc test above.

Reflection

One challenging thing for me while creating this report was trying to clean the pre_sleep column and just make it numeric, without any characters. One thing I was confident about was cleaning and merging the data, as well as conducting descriptive statistics. Next time, I would like to try to improve on cleaning specific columns like what I had to do with the pre_sleep column.