Types and Classes

Lecture 8

Dr. Elijah Meyer + Konnie Huang

Duke University
STA 199 - Fall 2022

September 21, 2022

Checklist

  • Open your ae-07 project in RStudio.

  • HW2 Due Tomorrow.

  • Exam 1 is coming (next week!)

Announcements

– Regrade requests

– Be detailed

– Ask clarification questions in Slack

– Single pipeline

Goals:

– Understand how R treats data

– ggplot practice

– Practice re-creating graphs

Prep Questions

Slido

Warm Up: Types of variables

03:00

Categorical or quantitative?

– Zipcode

– Ounces of water drank

– Height of students (measured tall / short)

– Hours spent playing video games

Types and Classes

– Type is how an object is stored in memory.

  • double: a real number stored in “double-precision floatint point format.”

  • integer: an integer (positive or negative).

– Class is metadata about the object that can determine how common functions operate on that object.

Types and Classes

class() - what kind of object is it (high-level)?

typeof() - what is the object’s data type (low-level)?

Changing the type of a variable changes it’s class, and how functions oberate on the object. We will get practice with this in the application exercise.

Application exercise

ae-07

  • Go to the course GitHub org and find your ae-07 (repo name will be suffixed with your GitHub name).
  • Clone the repo in your container, open the Quarto document in the repo, and follow along and complete the exercises.
  • Render, commit, and push your edits by the AE deadline – 3 days from today.

Recap of AE

– logical: a logical value.

– integer: an integer (positive or negative).

– double: a real number stored in “double-precision floatint point format.”

– character: a sequence of characters, called a “string” in other programming languages

More information can be found here: https://statsandr.com/blog/data-types-in-r/