Home

Menu

Loading wiki pages...

View
Wiki Version:
<h1><strong>R Programming for Research Workshop</strong></h1> <h2>Nick Michalak and Iris Wang</h2> <h2>University of Michigan LSA Department of Psychology</h2> <h2><strong>Required 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">The tidyverse style guide</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>Day 1. Installation and Introduction</strong></h2> <h3>Before Workshop</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>Find one or two datasets you know well and are OK with others seeing.<ol> <li>Preferably, find the raw (hasn't been "cleaned") data.</li> <li>Make a new folder. give it a good name. repeat with subfolders. (Hint: 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>Put your raw data in there, somewhere.</li> </ol> </li> </ul> </blockquote> <h3>During Workshop</h3> <blockquote> <ul> <li>Introduction / philosophy</li> <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> <li>R environment</li> <li>Running R code</li> <li>Demonstrations</li> <li>tidyverse</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>Day 2. Visualization</strong></h2> <h3>Before Workshop</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>Demonstrations</li> <li>Exercises</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>Day 3. Workflow and Data Transformation</strong></h2> <h3>Before Workshop</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>Coding Basics</li> <li>Naming</li> <li>Calling Functions</li> <li><code>rep()</code></li> <li><code>filter()</code></li> <li><code>arrange()</code></li> <li><code>select()</code></li> <li><code>mutate()</code></li> <li><code>summarise()</code></li> <li><code>gather()</code></li> <li><code>spread()</code></li> <li><code>full_join()</code>, <code>left_join()</code>, <code>right_join()</code>, <code>inner_join()</code></li> <li><code>ifelse()</code></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</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>Day 4. Summarizing and Modeling</strong></h2> <h3>Before Workshop</h3> <blockquote> <ul> <li>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><code>describe()</code> and <code>describeBy()</code></li> <li><code>t.test()</code></li> <li><code>lm()</code> and <code>Anova()</code><ul> <li><a href="https://people.ucsc.edu/~dgbonett/psyc204.html" rel="nofollow">contrasts</a></li> </ul> </li> <li><code>corr.test()</code></li> <li><code>pairs.panels()</code> and <code>cor.plot()</code></li> <li><code>lmer()</code></li> <li><code>sem()</code></li> <li><code>fa.parallel()</code> and <code>fa()</code></li> </ul> </blockquote> <h2><strong>Day 5. Your Data</strong></h2> <h3>Before the Workshop</h3> <blockquote> <p>Browse <a href="https://rmarkdown.rstudio.com/lesson-1.html" rel="nofollow">RMarkdown from RStudio</a> Skim <a href="http://r4ds.had.co.nz/workflow-projects.html" rel="nofollow">Workflow: projects</a> - find one or two datasets you know well and are OK with others seeing. 1. Preferably, find the raw (hasn't been "cleaned") data 2. Make a new folder. give it a good name. repeat with subfolders. (Hint: 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) 3. Put your raw data in there, somewhere - Skim <a href="http://style.tidyverse.org/" rel="nofollow">The tidyverse style guide</a> by Hadley Wickham</p> </blockquote> <h3>During the Workshop</h3> <blockquote> <ul> <li>R Projects</li> <li>R Markdown</li> <li>Importing data<ul> <li><code>read_csv()</code>, <code>read_spss()</code>, and <code>read_stata()</code></li> </ul> </li> <li>Writing code you and others can read </li> </ul> </blockquote> <h2><strong>R Resources</strong></h2> <h3><strong>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>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>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> <h2>Acknowledgements</h2> <blockquote> <ul> <li>Iris and I couldn't have done this alone. We thank all of these thoughtful and helpful people:<br> Josh Wondra (he started this workshop in the Psychology Department last summer and helped us take it over this summer); Brian Wallace and everyone at Psychology Student Academic Affairs (they approved us!); Rich Gonzalez (especially his Psychology 613/614 course); Adrienne Beltz and Pam Davis-Kean and everyone who's a part of the Psychology Methods Hour; Instructional Support Services and Blue Corps at the University of Michigan; and, of course, the R community, especially Hadley Wickham and Garrett Grolemund (they wrote the book!).</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.