Lecture Notes: Intro to R

Learning Objectives

  1. Become familiar with the STAT 545 website and syllabus.
  2. Explore basic R syntax.

Parallel Resources

Today’s class is a digest of the following resources:

Some additional resources that you might find useful:

Demonstration

Introductions

Course Platforms

Platforms for hosting course-related content:

  1. Slack (https://stat545classroom2023.slack.com/)

  2. Website (https://stat545.stat.ubc.ca/) – view this as your “launchpad”.

  3. A GitHub Organization for you to submit homework and projects to.

  4. Canvas (for grade management and worksheet submission)

Syllabus

  • Lecture topics
  • Deliverables

Working with jupyter; working with R syntax.

Worksheet A1 (.ipynb; viewable) is an autograded! worksheet covering some R basics. Let’s go through some of it. You won’t be submitting this worksheet for a grade, but future worksheets will count towards your grade..

What to do when you are stuck

Working with technology can be hard. Coding can be especially hard. Getting stuck is very common in both cases.

Very useful general skills for getting unstuck are to 1. learn to help yourself, and 2. learn how to productively ask for help. The content below gives self-help advice for acquiring this skill.

  • Google is your friend. Google is your friend. Google is your friend.

    • E.g. copy the error message, maybe strip out anything highly specific, such the name of your R objects, surround with quotes and Google it!
  • While you are getting started, I recommend you seek help within the STAT545 community first (try Slack!), before, e.g. posting to external forums. We are more cuddly.

  • This stackoverflow thread How to make a great R reproducible example? is fantastic. I find that, in the process of preparing my great reproducible example, I answer my own question 90% of the time. YMMV. So it is a useful exercise even if you aren’t ready to call in the experts yet. The process of stripping your problem down to its bare essence often reveals where the root issue lies. Highly recommended!

  • Search stackoverflow and include the [r] tag. Or the [ggplot2] tag. Or the [plyr] tag. You get the idea.

  • Check out The R Inferno (see the 9th circle: “Unhelpfully seeking help”).

If someone has the wit and knowledge to answer your question, they probably have other things they would like to do. Making your message clear, concise and user-friendly gives you the best hope of at least one of those strangers diverting their attention away from their life towards your problem.

… demonstrate the kind of attitude that leads to competence: alert, thoughtful, observant, willing to be an active partner in developing a solution

(Thanks to Jenny Bryan and her team for writing the majority of this)