Getting Started

Before we meet for our first class there are few things you should try at home to get started.

  1. Download and install R on your computer. This is the R website https://www.r-project.org
  2. Download and install R-studio. You must download and install R first before installing R-studio. The R-studio website is https://www.rstudio.com
  3. Create a free github account. The github website is https://github.com
  4. Download and install github desktop https://desktop.github.com
  5. At this point you should have downloaded R and R-studio to your own computer. This will allow you to run R and R-studio locally. It is also possible to run R-studio in the cloud through your web-browser. To do this you need to create an account with R-studio cloud. Create an account here https://rstudio.cloud. Note: In class we will be using a computer lab wit R-studio installed on the computers. You will have the option of using the lab computer, or bringing your own laptop, and/or using R-studio through the cloud.

Don’t worry if you ran into issues with these first steps, we will address them in class on Monday.

If you have R-studio working is there anything else you can do before we meet for the first time on Monday? Yes.

You can follow the video tutorial on creating an R markdown website with github pages on the video page. And, you can get started with some of the readings, and you can begin messing around in R. Here are some things to read:

  1. Programming for Psychologists, Chapter 1
  2. Programming for Psychologists, Chapter 2
  3. Navarros’ Section 1: Core Toolkit

We will be spending the first few weeks of the course working on solving different kinds of coding problems in R. These problems will help you learn the ins and outs of coding in R. You can get a head start by trying to solve the problems in this list of programming challenges.

1. R, R Markdown, Websites, & Github

Overview

  • Getting set-up with R, R-studio, using R-studio cloud, and Github.
  • Follow a tutorial to create a free Github account, and then create a webpage using R Markdown and host it for free on Github. Students will use their personal website throughout the course as a mechanism for submitting assignments and to document their progress learning R.
  • Introduction to basic programming concepts in R (variables, loops, logic, functions)

Assignment 1 (website)

Due date: M Feb 4th

  1. Create a website using R Markdown and host it on Github pages, then submit the link to your website on Blackboard for Assignment 1. We will create the website in class using this template https://github.com/CrumpLab/LabJournalWebsite
  2. Edit and customize your website to make it your own. Edit the journal page and rename it to “R Basics”.
  3. Use the new “R Basics” .rmd file to begin working through the list of programming challenges. For each problem create a new header, briefly describe the problem, then create a code-block and write code to solve the problem.
  4. Throughout this course you will likely have many questions about how to solve different kinds of problems in R. We will use Github’s issues tracking feature as a way for everyone to post questions and solutions. Go to the github repository for this course https://github.com/CrumpLab/psyc7709. You will see an issue tab, with a “say hello” issue posted. Please add a comment to this issue so that I know that you can post issues. Then, if you have a question about R, please create a new issue. The entire class should be monitoring the posted issues, and anyone who knows an answer can respond with a comment.

2. Basic Programming in R I

Overview

  • Continue working on solving programming challenges
  • More discussion on variable types in R, and using loops and logic to create simple algorithms.
  • Overview of useful intrinsic functions in R

Assignment 2 (R Basics I)

Due date: M Feb 11th

  1. Continue adding to your “R Basics” page to document progress in solving programming challenges. Upload link to website showing progress. Students to should attempt all of the simple programming challenges, and begin working on the harder problems. As you complete each problem it is a good idea to try and be creative by solving the problem in different ways. So, it is ok to have multiple solutions for each problem.
  2. New: The new assignment for this week is to learn about existing functions in R, these are called R intrinsics. I have created an assignment worksheet with instructions, https://crumplab.github.io/psyc7709_2019/Presentations/RInstrinsics.html. The assignment contains a list of existing functions. Your task is to create a page on your website. Then, copy the list of functions from the assignment. For each function, you will write a brief description (only needs to be a sentence) of what it does, and then you will write a code chunk demonstrating that you can use the function. This will help you become familiar with existing functions that you can use. If you get stuck and are unable to figure out what a function does, post your question on the github issues tab for this course https://github.com/CrumpLab/psyc7709/issues.

tips: I added a video showing how to add a new page to your R markdown website


3. Basic Programming in R II

Overview

  • Continue working on solving programming challenges
  • Writing functions in R

Assignment 3 (R Basics II)

Due date: M Feb 25th

  1. Last week to document progress in solving programming challenges. Upload link to website showing progress. Students should attempt and solve as many of the harder problems as they can.

  2. Create and share an R package containing custom functions on github. Follow the instructions in the R package assignment that we will discuss in class. Upload the link to your new github repository containing your R package to blackboard.

tips: I added a video showing how to create a new R package and publish it to github.com

  1. NEW this an addition to your assignment not discussed in class. The assignment instructions are in the github assignment document. This assignment gives you more practice using github features. You will be forking a repo, adding to the code, then making a pull-request to have your new changes be incorporated into the master repository. Also, you will be able to see other students solutions to two of the harder programming problems.

tips: I added a video showing how to fork and make a pull request


4. Data-Visualization

Overview

  • Introduction to the grammar of graphics ggplot2 package for data-visualization

Assignment 4 (Data-Vis)

Your assignment is to practice making graphs in ggplot2. Click this link to see the assignment instructions. You will be making a new R markdown page documenting your code for making graphs in the assignment. Load this page onto your website, then submit the link to the page on blackboard.

Due date: M Mar 4th


5. Data-Wrangling

We had a snow day for this class. Here is a short video tutorial to help you get started and complete the assignment for this week. We will go over everything here next class as well.

Overview

  • Loading Data into R
  • Data formatting (dataframes and data.tables)
  • Introduction to the dplyr package for filtering, selecting, augmenting, and summarizing data sets (and more).

Assignment 5 (Data-Wrangling)

  1. Class notes on Data-wrangling
  2. Example R Markdown analysis report
  3. Your Rmarkdown Assignment This links to the .rmd file, that you can use as a template to complete the assignment. Using this template file, create a new page on your website, and submit the link
  4. Answer sheet for assignment You can use this to check your work. If you don’t get the same numbers, then one of us did something wrong.

Due date: M Mar 18th


6. Common inferential tests

Overview

  • t-tests, anovas, and linear regresssion, and more in R
  • Using R to simulate null-hypotheses
  • Overview and discussion of midterm project (three parts due over the next three weeks)

Assignment 6 (Stats)


7. APA papers using Papaja

Overview

  • Introduction to creating reproducible APA manuscripts using the papaja package. Students learn how to use the template for writing an APA report in R Markdown, which allows them to embed their R-scripts for data-analysis into the manuscript, allowing others to reproduce their analysis.
  • Midterm project continued

Midterm Assignment (due M April 8th)

midterm project

  • part 1: Reproducible Report
  • part 2: Convert to APA-style report using papaja

8. Data simulation

Overview

  • Simulating data from scratch, and using monte-carlo methods for power analysis and sample-size planning.

Midterm Assignment (due M April 8th)

midterm project

  • part 3: Simulation based power anlaysis

9. Shiny Web Apps

Overview

  • Introduction to R Shiny for building interactive web-applications

Readings and Resources

  1. Class Notes on Shiny
  2. R shiny tutorials

Assignment 7 (Shiny)

  1. Make a R shiny app (it can do whatever you want to make).
  2. Host the app as a folder on Github, or upload to shinyapps.io cloud server (need to create free account).
  3. Submit link on Blackboard

Due date: M Apr 15th


10. Optimizing R scripts

Overview

  • Principles of scripting for efficient memory management, including using profiles packages for determining which parts of a script can be further optimized. Discussion of vectorization in R.

Assignment 7 (Optimization)

No Assignment


11. Open science and Final Project planning

Overview

  • Open science and transparency.

Final Project

Presentation due: M May 15th Paper due date: M May 20th


12. R Markdown Presentations

Overview

  • Using R Markdown and the xaringan package to compile R Markdown documents into slide presentations for the web.

Final Project

Presentation due: M May 15th Paper due date: M May 20th


13. R Markdown books

Overview

  • Introduction to using the R Markdown format to compile documents into web-books, .pdf’s, and epubs using the bookdown package.

Final Project

Presentation due: M May 15th Paper due date: M May 20th


14. Presentations

Overview

  • Final Project individual presentations

15. Final project

Overview