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"><em>R for Data Science: Import, Tidy, Transform, Visualize, and Model Data</em></a>. Sebastopol, CA: O&#39;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). <em>Hadley Wickham &quot;Data Science with R&quot;</em>. 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. <em>Variance Explained.</em> 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>. <em>Journal of Statistical Software, 59(10)</em>, 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 &quot;Data Science with R&quot;</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&#39;t been &quot;cleaned&quot;) 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 R Studio<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 R Studio</a></li> <li><a href="https://support.rstudio.com/hc/en-us/articles/200554736-How-To-Uninstall-RStudio-Desktop" rel="nofollow">uninstalling R Studio</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/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&#39;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 <em>Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems</em> (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>. <em>PLoS biology, 13(4)</em>, 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&#39;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 <em>Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems</em> (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>. <em>PLoS biology, 13(4)</em>, 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/data-import.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>read data</li> <li>piping</li> <li>wrangling</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 workshop</li> <li>exercises in wrangling your own data</li> <li>cheat sheets<ul> <li><a href="https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf" rel="nofollow">Data wrangling cheat sheet</a></li> </ul> </li> </ul> </blockquote> <h2><strong>day 4. summarizing and modeling</strong></h2> <h3>before workshop</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>skim 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. workflows and your data</strong></h2> <h3>before workshop</h3> <blockquote> <ul> <li>skim <a href="http://r4ds.had.co.nz/workflow-projects.html" rel="nofollow">Workflow: projects</a></li> <li>skim <a href="http://r4ds.had.co.nz/r-markdown.html" rel="nofollow">R Markdown</a> and <a href="https://rmarkdown.rstudio.com/lesson-1.html" rel="nofollow">R Markdown R Studio tutorial</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 the workshop</h3> <blockquote> <ul> <li>R Projects</li> <li>R Markdown</li> <li>workflow template</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">Quick-R</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">R Studio Cheat Sheets</a> just like it reads, these are cheat sheets for &quot;favorite&quot; 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">UCLA Institute for Digital Research and Education: R</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">The Personality Project: Using R for psychological research</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">Richard Gonzalez Advanced Statistical Methods Course Notes</a> My regression bible, complete with SPSS and R code for common procedures + detailed notes</li> <li><a href="http://ggplot2.tidyverse.org/index.html" rel="nofollow">tidyverse: ggplot2</a> ggplot2 bible (also check out the rest of the tidyverse website)</li> <li><a href="http://lavaan.ugent.be/" rel="nofollow">lavaan: latent variable analysis</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">RExRepos: R code examples for a number of common data analysis tasks</a> just like it reads, how-to guide for common procedures</li> <li><a href="http://rpubs.com/SusanEJohnston/7953" rel="nofollow">R Base Graphics: An Idiot&#39;s Guide</a> if you want to plot with Base graphics like an R hipster?a hipstR, if you will?here&#39;s a jumping off point</li> <li><a href="http://swirlstats.com/" rel="nofollow">{ swirl }: Learn R, in R</a> <em>&quot;swirl teaches you R programming and data science interactively, at your own pace, and right in the R console!&quot;</em></li> <li><a href="http://ademos.people.uic.edu/index.html" rel="nofollow">A language, not a letter: Learning statistics in R</a> <em>&quot;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.&quot;</em></li> <li><a href="http://stat545.com/index.html" rel="nofollow">STAT 545 @ UBC: Data wrangling, exploration, and analysis with R</a> <em>&quot;Learn how to explore, groom, visualize, and analyze data and make all of that reproducible, reusable, and shareable using R&quot;</em></li> <li><a href="https://designingexperiments.com/" rel="nofollow">designingexperiments.com</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> <li><a href="https://davidgohel.github.io/officer/index.html" rel="nofollow">officer package</a> package for creating word documents and powerpoint graphics in R</li> </ul> </blockquote> <h3><strong>texts</strong></h3> <blockquote> <ul> <li>Beaujean, A. A. (2014). <a href="https://blogs.baylor.edu/rlatentvariable/" rel="nofollow"><em>Latent variable modeling using R: A step-by-step guide</em></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"><em>Discovering statistics using R</em></a>. London: SAGE Publications.</li> <li>Gelman, A., & Hill, J. (2007). <a href="http://www.stat.columbia.edu/~gelman/arm/" rel="nofollow"><em>Data analysis using regression and multilevel/hierarchical models</em></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"><em>ModernDive: An Introduction to Statistical and Data Sciences via R.</em></a></li> <li>Navarro, D. (2015). <a href="https://health.adelaide.edu.au/psychology/ccs/teaching/lsr/" rel="nofollow"><em>Learning Statistics with R</em></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"><em>Advanced R</em></a>. Boca Raton, FL: CRC Press.</li> <li>Wickham, H. (2016). <a href="http://ggplot2.org/book/" rel="nofollow"><em>ggplot2: Elegant graphics for data analysis</em></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"><em>Mixed effects models and extensions in ecology with R</em></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.