Pro Yearly is on sale from $80 to $50! »

R Assignments using R Script

R Assignments using R Script

Here's how to set up your R Studio Project by adding the first R script in a folder for CLU PSYC 560 Exploratory Data Analysis and Visualization.


  1. R ASSIGNMENT SETUP Instructor: Jamie Bedics, PhD, ABPP 1

  2. Class Assignments • In this presentation, you will: 1. Create

    folders in your R Project 2. Add R Script to your folder for homework. The presentation assumes you already setup your R Project for your course and you opened it and are working in it
  3. First, open your R Project for the course.

  4. 1. Click on New Folder 2. For PSYC 560 type:

  5. Here’s your new folder in your R Project

  6. Add a script to the folder

  7. 1. Save it right away 3. Add `hw2-bedics` which is

    for Homework #2 4. Add your name at the end of all your material to help the instructor (we need to know who it belongs to when you turn it in!) 2. Save it the HW folder
  8. All set to write some code! Notice it’s in the

    `01-homework` folder
  9. Go back to your desktop folder Here’s what the new

    folder looks like on my desktop
  10. Tips for writing you R code using .r files 10

  11. Use # in your code: 1. The “#” allows you

    to type notes to yourself. It’s a way of commenting to yourself and also to anyone reviewing your code (like your instructor). 2. You only need one # to make a comment 4. You can use a lot of “#” to add structure to the document like what was done above 5. I recommend to use “#” and make comments profusely. The more you tell yourself what you’re doing the better.
  12. Load necessary libraries at the top of the script 1.

    Always load your libraries at the top of the script 2. tidyverse is a package that we will use a lot. 3. By calling “library(tidyverse)” we are opening the library which assumes it has already been installed in the console using: install.packages(“tidyverse”)
  13. Add four #### at the end of a major section

    • This will help organize your code so you can jump to places. • Like a table of contents • Sometimes our code can be very long
  14. Check this page out for more tips on running your

    data project