#pulls from the exclusions_summary tabyl created above
comments_only_count <- exclusions_summary %>% filter(exclude_coded == "comments only") %>% pull(n)
comments_only_count2 <- exclusions_summary$n[which(exclusions_summary$exclude_coded=="comments_only")]
time_only_count <- exclusions_summary %>% filter(exclude_coded == "time only") %>% pull(n)
variance_only_count <- exclusions_summary %>% filter(exclude_coded == "variance only") %>% pull(n)
total <- exclusions_summary %>% filter(exclude_coded == "Total") %>% pull(n)
kept <- exclusions_summary %>% filter(exclude_coded == "kept") %>% pull(n)11 Appendix
12 how to install R and RStudio on your machine
The marvellous Danielle Navarro has LOTS of useful R learning resources on her YouTube channel. This playlist about how to install R and RStudio is particularly useful; no matter which operating system you are dealing with… Dani has you covered.
13 how to install packages
You only need to install a package once on your machine. Once the package is installed, you will need to use library() to load the functions in it every time you want to use it, but the installation is a one time job. So you can either do it in the console, or using the packages tab.
13.1 option 1
Install a package by typing the following command with the name of the package you would like to install in the console.
install.packages("packagename")13.2 option 2
Alternatively, search for the package you would like to install in the packages tab.

Remember once you have installed a package, you will need to use the
library()function to load it before it will work.
13.3 useful packages for psychology
- tidyversethis is a cluster of super helpful data wrangling and visualisation tools.
- herethis package helps direct R to the correct place for files based on the current working directory.
- janitorthis package helps us clean up data - especially awkward variable names.
- qualtRicsthis package is helpful in reading in data files from Qualtrics… except for .sav SPSS format files! (see next)
- haventhis package is a good one for reading in .sav SPSS format files
- sjplotthis package is helpful for making a ‘codebook’ of your variables and values from imported .sav files
- surveytoolboxthis package is helpful in drawing out the value labels of variables imported in .sav format – note: because- surveytoolboxis on github and not CRAN, you’ll want to do the following two steps in the console. Note that we do this in the console since we only need to do it once! If the install asks you about updating packages, go ahead and do it! —(1) install the- devtoolspackage: install.packages(“devtools”) —(2) install via github: devtools::install_github(“martinctc/surveytoolbox”)
- ufsthis package (short for user friendly science) is a nice tool for computing the internal reliability of scales – note: one of the commands we will use in- ufsrequires the- psychpackage to be installed (but doesn’t need to be loaded via- library()). Ensure you install that first. Two steps: —-(1) install the `remotes`` package: install.packages(“remotes”) —-(2) install via github_lab: remotes::install_gitlab(‘r-packages/ufs’)
- apanice for making statistical output into APA style
- gtnice for making your tables look pretty
- apaTablesmakes nice APA-styled tables of correlation, ANOVA, regression etc. output
- reportis a package to help with results reporting
- psychis an umbrella package for lots of common psych tasks
- ezis a great package for stats, including analysis of variance
- emmeansis helpful for comparing specific means in a factorial design
14 using inline code
JR maybe this piece needs to go in a separate chapter about writing with RMarkdown, papaja etc
Use of inline code is really helpful in avoiding transcription errors and saving time when writing up! Here, we use code to pull in some descriptive statistics from the exclusion reason table we made above:
INSERT INLINE EXAMPLE HERE
15 helpful console commands
- names(objectname) - returns a list of variable names for that dataframe, making it less likely you will type things incorrectly
- getwd() - returns the path to the current working directory. Run this in the console.
- rm(objectname) - removes the object from your global environment. Can be helpful in cleaning up any ‘test’ objects you make while troubleshooting code.
- ?package - brings up the Help info for that package
- ?function - brings up the Help info for that function
16 useful keyboard shortcuts
Option-Command-I = inserts a new code chunk Command-Enter = runs the chunk of code that your cursor is in