## PILL STUDY - CORONA FOLLOW UP ## LIFESTYLE # Lotte P. Brinkhof - May 2020 #Load functions: ---- #R functions library(readr); library(dplyr); library(reshape); library(reshape2); library(Rmisc) library(doBy); library(car); library(Hmisc); library(psych); library(utils); library(plotrix) library(readxl); options(contrasts=c("contr.sum","contr.poly")); library(afex); library(rethinking); library(ramify); library(imputeTS); library(readxl); library(nparLD); library(effsize) is.even <- function(x) x %% 2 == 0 #Customized functions load("Lifestyle_clean.Rdata") #Color settings ---- cold = "Grey30" #Load data: ---- NOTE: PATHS NEED TO BE CHANGED TO THE APPROPRIATE FOLDER A_FollowUp <- read_csv(".../Data/A.FollowUp.COVID.May2020.csv"); A_FollowUp <- as.data.frame(A_FollowUp) A_FollowUp <- A_FollowUp[-c(which(A_FollowUp$ppnr == 274,)[2]),] Lifestyle <- Lifestyle_clean(A_FollowUp); save(Lifestyle, file = "Lifestyle.Rdata") #Analyses: ---- Lifestyle_long <- melt(Lifestyle, id = c("ppnr", "Group", "Condition")) summaryBy(Eat~Group, data = Lifestyle, FUN = c(mean,sd,median,min,max)); summaryBy(Sport~Group, data = Lifestyle, FUN = c(mean,sd,median,min,max)) summaryBy(Sleep~Group, data = Lifestyle, FUN = c(mean,sd,median,min,max)) summaryBy(Drink~Group, data = Lifestyle, FUN = c(mean,sd,median,min,max), na.rm = T) summaryBy(Smoke~Group, data = Lifestyle, FUN = c(mean,sd,median,min,max), na.rm = T) par(mfrow=c(1,4)) barcenters <- boxplot(Lifestyle$Eat, col = cold, xaxt = "n", ylab = "Much unhealthier - much healthier", xlab = "Eat", frame = F, pch = 19, ylim = c(0,100)) barcenters <- boxplot(Lifestyle$Sport, col = cold, xaxt = "n", ylab = "Much less - much more", xlab = "Sport", frame = F, pch = 19, ylim = c(0,100)) barcenters <- boxplot(Lifestyle$Sleep, col = cold, xaxt = "n", ylab = "Much worse - much better", xlab = "Sleep", frame = F, pch = 19, ylim = c(0,100)) barcenters <- boxplot(Lifestyle$Drink, col = cold, xaxt = "n", ylab = "Much less - much more", xlab = "Drink", frame = F, pch = 19, ylim = c(0,100)) barcenters <- boxplot(Lifestyle$Smoke, col = cold, xaxt = "n", ylab = "Much less - much more", xlab = "Smoke", frame = F, pch = 19, ylim = c(0,100)) #Statistics wilcox.test(Lifestyle$Eat, mu = 50, alternative = "two.sided") #people started eating healthier quantile(Lifestyle$Eat) rcompanion::wilcoxonOneSampleR(Lifestyle$Eat, mu = 50) wilcox.test(Lifestyle$Sport, mu = 50, alternative = "two.sided") #many variation quantile(Lifestyle$Sport) rcompanion::wilcoxonOneSampleR(Lifestyle$Sport, mu = 50) wilcox.test(Lifestyle$Sleep, mu = 50, alternative = "two.sided") quantile(Lifestyle$Sleep) rcompanion::wilcoxonOneSampleR(Lifestyle$Sleep, mu = 50) wilcox.test(Lifestyle$Drink, mu = 50, alternative = "two.sided") quantile(Lifestyle$Drink, na.rm= T) rcompanion::wilcoxonOneSampleR(Lifestyle$Drink, mu = 50) wilcox.test(Lifestyle$Smoke, mu = 50, alternative = "two.sided")