Home

Menu

Loading wiki pages...

View
Wiki Version:
<h1><strong>R Programming for Psychology Research</strong></h1> <blockquote> <h2>Nick Michalak</h2> <h2>Presented at <a href="https://www.improvingpsych.org/SIPS2019/" rel="nofollow">SIPS 2019</a></h2> <h2>University of Michigan, Department of Psychology</h2> <h3><strong>email.</strong> <a href="nickmm@umich.edu" rel="nofollow"><strong>nickmm@umich.edu</strong></a></h3> <h3><strong>twitter.</strong> <a href="https://twitter.com/nmmichalak" rel="nofollow"><strong>@nmmichalak</strong></a></h3> </blockquote> <h2><strong>Important SIPS 2019 Links</strong></h2> <blockquote> <ul> <li> <h3><a href="https://docs.google.com/document/d/1OhA35IWpGgrDupYkPEqk9FAOW4d3Qh1_ZtsqzcLlLQo/edit" rel="nofollow"><strong>Workshop Landing Page</strong></a></h3> </li> <li> <h3><a href="https://sips-2019.slack.com/messages/w_intro_to_r" rel="nofollow"><strong>Workshop Slack Channel</strong></a></h3> </li> </ul> </blockquote> <h2><strong>Prerequisites</strong></h2> <blockquote> <p>Ideally, attendees will have wiped R and R Studio from their computers and re-installed R and R Studio before the session starts (see Part 1 below). This prevents us from spending too much time troubleshooting installation.</p> </blockquote> <h2><strong>Core Texts</strong></h2> <blockquote> <ul> <li>Wickham, H., & Grolemund, G. (2017). <a href="http://r4ds.had.co.nz/" rel="nofollow"><strong>R for Data Science: Import, Tidy, Transform, Visualize, and Model Data</strong></a>. Sebastopol, CA: O'Reilly Media, Inc.</li> <li><a href="http://style.tidyverse.org/" rel="nofollow"><strong>The tidyverse style guide</strong></a> by Hadley Wickham</li> </ul> </blockquote> <h2><strong>Philosophy</strong></h2> <blockquote> <ul> <li>ReadCollegePDX (2015, October 19). <strong>Hadley Wickham "Data Science with R"</strong>. Retrieved from <a href="https://youtu.be/K-ss_ag2k9E?list=PLNtpLD4WiWbw9Cgcg6IU75u-44TrrN3A4" rel="nofollow">https://youtu.be/K-ss_ag2k9E?list=PLNtpLD4WiWbw9Cgcg6IU75u-44TrrN3A4</a></li> <li>Robinson, D. (2017, July 05). Teach the tidyverse to beginners. <strong>Variance Explained.</strong> Retreived from <a href="http://varianceexplained.org/r/teach-tidyverse/" rel="nofollow">http://varianceexplained.org/r/teach-tidyverse/</a></li> <li>Wickham, H. (2014). <a href="http://vita.had.co.nz/papers/tidy-data.html" rel="nofollow">Tidy data</a>. <strong>Journal of Statistical Software, 59(10)</strong>, 1-23.</li> </ul> </blockquote> <h2><strong>Part 1. Installation and Introduction</strong></h2> <h3>Before Workshop</h3> <blockquote> <ul> <li>Installing (and uninstalling) R and RStudio<ul> <li>Installing R (<a href="https://stats.idre.ucla.edu/r/icu/installing-r-for-macintosh/" rel="nofollow">Macintosh</a> / <a href="https://stats.idre.ucla.edu/r/icu/installing-r-for-windows/" rel="nofollow">Windows</a>)</li> <li>Uninstalling R (<a href="https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Uninstalling-under-macOS" rel="nofollow">Macintosh</a> / <a href="https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Uninstallation" rel="nofollow">Windows</a>)</li> <li><a href="https://www.rstudio.com/products/rstudio/download/" rel="nofollow">Installing RStudio</a></li> <li><a href="https://support.rstudio.com/hc/en-us/articles/200554736-How-To-Uninstall-RStudio-Desktop" rel="nofollow">Uninstalling RStudio</a></li> </ul> </li> </ul> </blockquote> <h3>Helpful Background</h3> <blockquote> <ul> <li>Skim <a href="http://r4ds.had.co.nz/introduction.html" rel="nofollow">introduction</a> (Wickham & Grolemund)</li> <li>Browse <a href="http://tidyverse.org/" rel="nofollow">tidyverse.org</a></li> <li>Skim <a href="https://youtu.be/K-ss_ag2k9E?list=PLNtpLD4WiWbw9Cgcg6IU75u-44TrrN3A4" rel="nofollow">Hadley Wickham "Data Science with R"</a> (ReedCollegePDX, 2016)</li> <li>Skim some data management best practices from the <a href="https://library.stanford.edu/research/data-management-services/data-best-practices" rel="nofollow">Stanford Library</a> or the <a href="http://guides.lib.umich.edu/c.php?g=538509&amp;p=3686046" rel="nofollow">Michigan Library</a> guide)</li> <li>Browse <a href="https://rmarkdown.rstudio.com/lesson-1.html" rel="nofollow">RMarkdown from RStudio</a></li> <li>Skim <a href="http://r4ds.had.co.nz/workflow-projects.html" rel="nofollow">Workflow: projects</a></li> <li>Skim <a href="http://style.tidyverse.org/" rel="nofollow">The tidyverse style guide</a> by Hadley Wickham</li> </ul> </blockquote> <h3>During Workshop</h3> <blockquote> <ul> <li>Introduction / Philosophy</li> <li>R Environment</li> <li>R Objects</li> <li>Functions</li> <li>tidyverse</li> <li>Extracting and Replacing</li> <li>Exercises</li> <li>Resources</li> <li>Cheat Sheets<ul> <li><a href="http://github.com/rstudio/cheatsheets/raw/master/source/pdfs/base-r.pdf" rel="nofollow">Base R Cheat Sheet</a></li> </ul> </li> </ul> </blockquote> <h2><strong>Part 2. Visualization</strong></h2> <h3>Helpful Background</h3> <blockquote> <ul> <li>Skim <a href="http://r4ds.had.co.nz/data-visualisation.html" rel="nofollow">Data visualization</a> and <a href="http://r4ds.had.co.nz/data-import.html" rel="nofollow">Data import</a> (Wickham & Grolemund)</li> <li>Skim <a href="http://magrittr.tidyverse.org/" rel="nofollow">magrittr</a> and <a href="http://ggplot2.tidyverse.org/" rel="nofollow">ggplot2</a></li> <li>Skim <a href="https://en.wikipedia.org/wiki/Anscombe%27s_quartet" rel="nofollow">Anscombe's quartet</a></li> <li>Skim Matejka, J., & Fitzmaurice, G. (2017, May). <a href="https://www.autodeskresearch.com/publications/samestats" rel="nofollow">Same stats, different graphs: Generating datasets with varied appearance and identical statistics through simulated annealing</a>. In <strong>Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems</strong> (pp. 1290-1294). ACM.</li> <li>Skim Weissgerber, T. L., Milic, N. M., Winham, S. J., & Garovic, V. D. (2015). <a href="http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1002128" rel="nofollow">Beyond bar and line graphs: time for a new data presentation paradigm</a>. <strong>PLoS biology, 13(4)</strong>, e1002128.</li> <li>Skim McCabe, C. J., Kim, D. S., & King, K. M. (2018). <a href="http://journals.sagepub.com/doi/full/10.1177/2515245917746792" rel="nofollow">Improving Present Practices in the Visual Display of Interactions</a>. <em>Advances in Methods and Practices in Psychological Science, 2515245917746792</em>.<ul> <li>Play with their R Shiny web application that accompanies the paper: <a href="https://connorjmccabe.shinyapps.io/interactive/" rel="nofollow">interActive: A tool for the visual display of interactions</a> </li> </ul> </li> </ul> </blockquote> <h3>During Workshop</h3> <blockquote> <ul> <li>Introduction and Demonstration<ul> <li><a href="https://en.wikipedia.org/wiki/Anscombe%27s_quartet" rel="nofollow">Anscombe's quartet</a></li> <li>Matejka, J., & Fitzmaurice, G. (2017, May). <a href="https://www.autodeskresearch.com/publications/samestats" rel="nofollow">Same stats, different graphs: Generating datasets with varied appearance and identical statistics through simulated annealing</a>. In <strong>Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems</strong> (pp. 1290-1294). ACM.</li> <li>Weissgerber, T. L., Milic, N. M., Winham, S. J., & Garovic, V. D. (2015). <a href="http://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1002128" rel="nofollow">Beyond bar and line graphs: time for a new data presentation paradigm</a>. <strong>PLoS biology, 13(4)</strong>, e1002128.</li> </ul> </li> <li>ggplot2 and the grammar of graphics</li> <li>Scatterplots</li> <li>Histograms</li> <li>Boxplots</li> <li>Mean and Error Bar Plots</li> <li>Exercises</li> <li>Resources</li> <li>Cheat Sheets<ul> <li><a href="https://www.rstudio.com/wp-content/uploads/2016/11/ggplot2-cheatsheet-2.1.pdf" rel="nofollow">Data Visualization Cheat Sheet</a></li> <li><a href="https://github.com/rstudio/cheatsheets/raw/master/source/pdfs/data-import-cheatsheet.pdf" rel="nofollow">Data Import Cheat Sheet</a></li> </ul> </li> </ul> </blockquote> <h2><strong>Part 3. Data Wrangling</strong></h2> <h3>Helpful Background</h3> <blockquote> <ul> <li>Skim <a href="http://r4ds.had.co.nz/workflow-basics.html" rel="nofollow">Workflow: basics</a>, <a href="http://r4ds.had.co.nz/transform.html" rel="nofollow">Data transformation</a>, and <a href="http://r4ds.had.co.nz/tidy-data.html" rel="nofollow">Tidy data</a> (Wickham & Grolemund)</li> <li>Skim <a href="http://style.tidyverse.org/files.html" rel="nofollow">Files</a> and <a href="http://style.tidyverse.org/syntax.html" rel="nofollow">Syntax</a> from the tidyverse style guide (Wickham)</li> </ul> </blockquote> <h3>During Workshop</h3> <blockquote> <ul> <li>Selecting Variables</li> <li>Creating and Recoding Variables</li> <li>Selecting Rows</li> <li>Counting Cases</li> <li>"Long-ing" and "Wide-ing" Data</li> <li>Exercises in <a href="https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf" rel="nofollow">wrangling</a> your own data Resources</li> <li>Cheat Sheets<ul> <li><a href="https://github.com/rstudio/cheatsheets/raw/master/source/pdfs/data-transformation-cheatsheet.pdf" rel="nofollow">Data Transformation Cheat Sheet</a></li> </ul> </li> </ul> </blockquote> <h2><strong>Part 4. Summarizing and Modeling</strong></h2> <h3>Helpful Background</h3> <blockquote> <ul> <li>Skim your favorite regression or ANOVA text, or any tutorials at <a href="https://designingexperiments.com/supplements/" rel="nofollow">https://designingexperiments.com/supplements/</a></li> <li>Skim <code>help("lm")</code>, <code>help("car")</code>, and <code>help("afex")</code></li> <li>Skim <a href="https://cran.r-project.org/web/packages/psych/vignettes/intro.pdf" rel="nofollow">An introduction to the psych package: Part I: Data entry and data description</a></li> <li>Skim <a href="https://cran.r-project.org/web/packages/psych/vignettes/overview.pdf" rel="nofollow">An introduction to the psych package: Part II Scale construction and psychometrics</a></li> <li>Skim <a href="http://lavaan.ugent.be/tutorial/index.html" rel="nofollow">lavaan: tutorial</a></li> <li>Judd, C. M., Westfall, J., & Kenny, D. A. (2017). <a href="http://jakewestfall.org/publications/JWK_AnnRev.pdf" rel="nofollow">Experiments with more than one random factor: Designs, analytic models, and statistical power</a>. <em>Annual Review of Psychology, 68</em>, 601-625.</li> </ul> </blockquote> <h3>During Workshop</h3> <blockquote> <ul> <li>Descriptive Statistics</li> <li>t-tests</li> <li>Linear Regression</li> <li>ANOVA</li> <li>Correlations</li> <li>Mixed Effects Regression</li> <li>SEM</li> <li>Factor Analysis</li> </ul> </blockquote> <h2><strong>Part 5. Templates for Prepping, Summarizing, and Modeling Data</strong></h2> <h3>During Workshop</h3> <blockquote> <ul> <li>Try to complete exercise templates (.Rmd files ending with "exercise")</li> <li>Use exercise keys when you get stuck (.Rmd or .html files ending with "key")</li> </ul> </blockquote> <h1><strong>Some R Resources</strong></h1> <h2><strong>Some Other Folks' R Learning Materials</strong></h2> <blockquote> <ul> <li>Danielle Navarro's <a href="https://learningstatisticswithr.com/" rel="nofollow"><strong>Learning Statistics with R</strong></a></li> <li>Daniel Nettle's <a href="https://www.danielnettle.org.uk/r-modelling/" rel="nofollow"><strong>R Course</strong></a></li> <li>Dale Barr and Lisa DeBruine's <a href="https://gupsych.github.io/data_skills/index.html" rel="nofollow"><strong>Data Skills for Reproducible Science</strong></a></li> <li>Sean Murphy's <a href="https://github.com/seanchrismurphy/A-Psychologists-Guide-to-R" rel="nofollow"><strong>A Psychologist's Guide to R</strong></a></li> <li>Curran-Bauer Analytics <a href="https://curranbauer.org/inform/" rel="nofollow">Workshop Materials</a><ul> <li>In particular, see <a href="https://curranbauer.org/inform/#software" rel="nofollow">Fitting Structural Equation Models with the lavaan Package in R</a></li> </ul> </li> </ul> </blockquote> <h3><strong>Some Websites</strong></h3> <blockquote> <ul> <li><a href="http://www.statmethods.net/" rel="nofollow"><strong>Quick-R</strong></a> a roadmap to the language and the code necessary to get started quickly (i.e. tutorials)</li> <li><a href="https://www.rstudio.com/resources/cheatsheets/" rel="nofollow"><strong>RStudio Cheat Sheets</strong></a> just like it reads, these are cheat sheets for "favorite" R packages and more (e.g. dplyr, ggplot2, base, R Markdown, regular expressions)</li> <li><a href="http://stats.idre.ucla.edu/r/" rel="nofollow"><strong>UCLA Institute for Digital Research and Education: R</strong></a> statistics and programming tutorials for R, among other helpful related resources</li> <li><a href="https://www.personality-project.org/r/r.guide.html" rel="nofollow"><strong>The Personality Project: Using R for psychological research</strong></a> seemingly endless tutorials and explainers about R programming for (personality-themed) psychology research; also, some tutorials cover the psych package, which is written by Michigan Psychology alumni, William Revelle (1973)</li> <li><a href="http://www-personal.umich.edu/~gonzo/coursenotes/" rel="nofollow"><strong>Richard Gonzalez's Advanced Statistical Methods Course Notes</strong></a> Nick's regression bible, complete with SPSS and R code for common procedures + detailed notes</li> <li><a href="https://people.ucsc.edu/~dgbonett/docs/psyc204/204RFunctions.docx" rel="nofollow"><strong>Doug Bonett's Quantitative Data Analysis Course R Functions</strong></a> includes functions for testing linear contrasts (standardized and unstandardized) that don't assume equal variances</li> <li><a href="http://ggplot2.tidyverse.org/index.html" rel="nofollow"><strong>tidyverse: ggplot2</strong></a> ggplot2 bible (also check out the rest of the tidyverse website)</li> <li><a href="http://lavaan.ugent.be/" rel="nofollow"><strong>lavaan: latent variable analysis</strong></a> overview and tutorials for the best sem package (IMO) in R (disclaimer: no support for discrete latent variables, aka mixture modeling, latent class analysis)</li> <li><a href="http://www.uni-kiel.de/psychologie/rexrepos/index.html" rel="nofollow"><strong>RExRepos: R code examples for a number of common data analysis tasks</strong></a> just like it reads, how-to guide for common procedures</li> <li><a href="http://rpubs.com/SusanEJohnston/7953" rel="nofollow"><strong>R Base Graphics: An Idiot's Guide</strong></a> if you want to plot with Base graphics like an R hipster?a hipstR, if you will?here's a jumping off point</li> <li><a href="http://swirlstats.com/" rel="nofollow"><strong>{ swirl }: Learn R, in R</strong></a> <em>"swirl teaches you R programming and data science interactively, at your own pace, and right in the R console!"</em></li> <li><a href="http://ademos.people.uic.edu/index.html" rel="nofollow"><strong>A language, not a letter: Learning statistics in R</strong></a> <em>"This online collection of tutorials was created by graduate students in psychology as a resource for other experimental psychologists interested in using R for statistical analyses and graphics. Each chapter was created to provide an overview of how to code a particular topic in the R language."</em></li> <li><a href="http://stat545.com/index.html" rel="nofollow"><strong>STAT 545 @ UBC: Data wrangling, exploration, and analysis with R</strong></a> <em>"Learn how to explore, groom, visualize, and analyze data and make all of that reproducible, reusable, and shareable using R"</em></li> <li><a href="https://designingexperiments.com/" rel="nofollow"><strong>designingexperiments.com</strong></a> site accompanies Designing Experiments and Analyzing Data: A Model Comparison Perspective (3rd edition; Maxwell, Delaney, & Kelley, 2018). It's full of modeling examples for R, but it also includes some extremely useful website applications for power analyses for all sorts of common designs</li> </ul> </blockquote> <h3><strong>Some Texts</strong></h3> <blockquote> <ul> <li>Beaujean, A. A. (2014). <a href="https://blogs.baylor.edu/rlatentvariable/" rel="nofollow"><strong>Latent variable modeling using R: A step-by-step guide</strong></a>. New York, NY: Routledge.</li> <li>Field, A., Miles., J., & Field, Z. (2012). <a href="https://us.sagepub.com/en-us/nam/discovering-statistics-using-r/book236067%20#resources" rel="nofollow"><strong>Discovering statistics using R</strong></a>. London: SAGE Publications.</li> <li>Gelman, A., & Hill, J. (2007). <a href="http://www.stat.columbia.edu/~gelman/arm/" rel="nofollow"><strong>Data analysis using regression and multilevel/hierarchical models</strong></a>. New York, NY: Cambridge University Press.</li> <li>Ismay, C. & Kim, A.Y. (2017). <a href="https://ismayc.github.io/moderndiver-book/" rel="nofollow"><strong>ModernDive: An Introduction to Statistical and Data Sciences via R.</strong></a></li> <li>Healy, K. (2018). <a href="http://socviz.co/lookatdata.html" rel="nofollow"><strong>Data visualization: A practical introduction</strong></a>. Princeton University Press.</li> <li>Navarro, D. (2015). <a href="https://health.adelaide.edu.au/psychology/ccs/teaching/lsr/" rel="nofollow"><strong>Learning Statistics with R</strong></a>. Raleigh, North Carolina: Lulu Press, Inc.</li> <li>Maxwell, Delaney, & Kelley, (2018). <a href="https://www.routledge.com/Designing-Experiments-and-Analyzing-Data-A-Model-Comparison-Perspective/Maxwell-Delaney-Kelley/p/book/9781138892286" rel="nofollow"><strong>Designing experiments and analyzing data: A model comparison perspective. (3rd ed.)</strong></a>. Routledge.</li> <li>Wickham, H. (2015). <a href="http://adv-r.had.co.nz/" rel="nofollow"><strong>Advanced R</strong></a>. Boca Raton, FL: CRC Press.</li> <li>Wickham, H. (2016). <a href="http://ggplot2.org/book/" rel="nofollow"><strong>ggplot2: Elegant graphics for data analysis</strong></a>. New York, NY: Springer.</li> <li>Zuur, A. F., Ieno, E. N., Walker, N. J., Saveliev, A. A., & Smith, G. M. (2009). <a href="https://www.amazon.com/Effects-Extensions-Ecology-Statistics-Biology/dp/0387874577" rel="nofollow"><strong>Mixed effects models and extensions in ecology with R</strong></a>. New York, NY: Springer.</li> </ul> </blockquote>
OSF does not support the use of Internet Explorer. For optimal performance, please switch to another browser.
Accept
This website relies on cookies to help provide a better user experience. By clicking Accept or continuing to use the site, you agree. For more information, see our Privacy Policy and information on cookie use.
Accept
×

Start managing your projects on the OSF today.

Free and easy to use, the Open Science Framework supports the entire research lifecycle: planning, execution, reporting, archiving, and discovery.