library(knitr) library(rmdformats) install.packages("rmdformats") library(tibble) library(readr) dat1 <- read_csv("bigfive.csv") ## NOTICE THE DIFFERENCE HERE: iris[,1] as_tibble(iris)[,1] as_tibble(iris)[,1] iris[,1] as.tibble(iris) as_tibble(iris) library(tibble) #library(formatR) glimpse(data2) library(knitr) library(rmdformats) ## Global options options(max.print="75") opts_chunk$set(echo=TRUE, cache=TRUE, prompt=FALSE, tidy=TRUE, comment=NA, message=FALSE, warning=FALSE) opts_knit$set(width=75) library(tibble) library(readr) dat1 <- read_csv("bigfive.csv") ## NOTICE THE DIFFERENCE HERE: iris[,1] as_tibble(iris)[,1] #head(data) library(readxl) data2 <- read_excel("bigfive-codingcomplete.xlsx") ## do the same thing with gdata read.xls #data <- read.xls("bigfive-codingcomplete.xlsx") library(tibble) #library(formatR) glimpse(data2) print(data2) curl_download("https://lo.unisa.edu.au/pluginfile.php/1020313/mod_book/chapter/106604/HLTH1025_2016.xlsx",destfile="HLTH1025_2016.xlsx") library(curl) ## This won't work! #data3 <- read_excel("https://lo.unisa.edu.au/pluginfile.php/1020313/mod_book/chapter/106604/HLTH1025_2016.xlsx") curl_download("https://lo.unisa.edu.au/pluginfile.php/1020313/mod_book/chapter/106604/HLTH1025_2016.xlsx",destfile="HLTH1025_2016.xlsx") data3 <- read_excel("HLTH1025_2016.xlsx",sheet="Data") codesheet <- read_excel("HLTH1025_2016.xlsx",sheet=1,skip=2) data3 <- read_excel("HLTH1025_2016.xlsx",sheet="Data") codesheet <- read_excel("HLTH1025_2016.xlsx",sheet=1,skip=2) library(haven) data3.spss <- read_spss("https://lo.unisa.edu.au/pluginfile.php/1020313/mod_book/chapter/106604/HLTH1025_2016.sav") data3.spss glimpse(data3.spss) install.packages("prepdat") library("prepdat") ##This might be needed on windows: #install.packages("rtools") utils::unzip("data.zip",exdir="data") ##unzip the data file. This may not work on some platforms, and you may need to do it by hand. library(prepdat) data <- file_merge(folder_path="data", has_header=T, raw_file_extension="csv", raw_file_name="globallocal*") head(data) data$within <- as.numeric(data$correctresp) dat2 <- prep(dataset=data, dvc="rt", id="subnum", within_vars=c("within"), save_results=F, save_summary=T, results_path="data") | 3 || 5 data library(dplyr) select(data,subnum:type) data %>% select(subnum:type) slice(select(data,subnum:type),10:20) filter(slice(select(data,subnum:type),10:20),trial<15) data %>% select(subnum:type) %>% slice(10:20) %>% filter(trial<15) data2 %>% select(Subnum,Gender, Education, Extra:Openness) data2 data2 %>% select(Subnum,Gender, Education, Extra:Openness) data2 %>% select(Subnum,Gender, Education, Extra:Openness) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) %>% group_by(Gender, Education) %>% summarize (E=mean(Extra), A=mean(Agreeable), C=mean(Consc), N=mean(Neuro),O=mean(Openness)) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) %>% group_by(Gender, Education) %>% summarize (E=mean(Extra), A=mean(Agreeable), C=mean(Consc), N=mean(Neuro),O=mean(Openness)) %>% pivot_longer(cols=E:O) library(tidyr) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) %>% group_by(Gender, Education) %>% summarize (E=mean(Extra), A=mean(Agreeable), C=mean(Consc), N=mean(Neuro),O=mean(Openness)) %>% pivot_longer(cols=E:O) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) %>% group_by(Gender, Education) %>% summarize (E=mean(Extra), A=mean(Agreeable), C=mean(Consc), N=mean(Neuro),O=mean(Openness)) %>% pivot_longer(cols=E:O) %>% ggplot(aes(x=Gender,group=Education,color=Education,y=value)) + geom_point() + geom_line() +facet_wrap(.~name,ncol=5) + theme_bw() + ylim(1,5) library(ggplot2) data2 %>% select(Subnum,Gender, Education, Extra:Openness) %>% mutate(Education=recode(Education, `1`="1.High school",`2`="2.College degree",`3`="3.Post-secondary degree")) %>% group_by(Gender, Education) %>% summarize (E=mean(Extra), A=mean(Agreeable), C=mean(Consc), N=mean(Neuro),O=mean(Openness)) %>% pivot_longer(cols=E:O) %>% ggplot(aes(x=Gender,group=Education,color=Education,y=value)) + geom_point() + geom_line() +facet_wrap(.~name,ncol=5) + theme_bw() + ylim(1,5) install.packages(c("broom", "callr", "cpp11", "datawizard", "deSolve", "dplyr", "effectsize", "emmeans", "expm", "gam", "generics", "ggrepel", "gtools", "hms", "insight", "jpeg", "maptools", "MatrixModels", "minqa", "network", "parameters", "pbapply", "performance", "pkgload", "plotly", "plyr", "processx", "ps", "purrr", "R.utils", "Rcpp", "RcppEigen", "readxl", "rgl", "sp", "statnet.common", "testthat", "tidyr", "tidyselect", "tigris", "vioplot")) unlink("data-libraries_cache", recursive = TRUE) knit_with_parameters("~/Dropbox/courses/5220-s2023/web-5220/psy5220/daily/Day01/data-libraries.Rmd")