RStudio

Week 1

Overview

  1. Read the syllabus
  2. Install R
  3. Install RStudio
  4. Go through the videos linked below.
  5. Review the week 1 slides
  6. Attend the lab session to go through the Lab Component of Homework 1.
  7. Complete Homework 1

This week I will introduce the course and our approach for the term. We will also introduce RStudio and go through some basic hands-on tasks that will be reinforced in the labs this week.

RStudio Cloud

If for some reason you are not able to install R and RStudio on your own computer, there is another option, a cloud-based version of RStudio that you can access using your web browser: Posit Cloud. There is a free version of it and also paid versions that provide more compute resources if you need them.

It is better for you to have R and RStudio installed on your own computer but Posit Cloud is there as another option if you need it.

Videos

RStudio basics

Open up RStudio on your computer and watch this video by Matt Crump:

You should be able to answer the following questions:

  1. Do you know where the console is, and what it does?
  2. Do you know where the editor window is and what it does.
  3. Do you know the difference between writing code in the editor in window, and running code in the console?
  4. What is the environment tab, and what does it show you?
  5. How to clear the workspace
  6. What is the files tab, and what does it show you?
  7. How to copy a file
  8. How to rename a file
  9. How to move a file

R scripts & R Markdown files

Open up RStudio on your computer and watch this video:

You should be able to answer the following questions:

  1. Make a new R markdown file
  2. Delete the template to start fresh
  3. Save your R markdown file
  4. Add some notes and code to the file
  5. know how to make an R code block
  6. Knit the file
  7. Know how to set eval=FALSE so the code bock does not run
  8. Know how to set echo=FALSE to the code block is not displayed
  9. Add comments to a code block
  10. Make a new R script
  11. add code to an r script
  12. add comments to an r script
  13. save an r script
  14. run code from an r script

Basic R stuff

Open up RStudio on your computer and watch this video:

You should be able to answer the following questions:

  1. Do basic math with R
  2. Store a number in a variable
  3. Store a string in a variable
  4. Store multiple numbers in a variable
  5. Store multiple strings in a variable
  6. Index a particular location in a variable
  7. Replace a particular value in a variable at a particular location
  8. Do basic math with numbers in variable.
  9. Hot key for running a line a code
  10. Copy and paste code into console and press enter
  11. press play in Rmd file to run code in code block
  12. Select any number of lines and run code using hot key

R packages

Open up RStudio on your computer and watch this video:

You should be able to answer the following questions:

  1. Know how to install an R package
  2. Know how to load a package using library()
  3. Know how to load a package by clicking it in the packages a tab
  4. Understand why knitting would fail if you did not load a library you need in your .rmd file.