Introduction

Dataset source: https://onlinestatbook.com/2/case_studies/binge.html

Model script

# This is a note to myself, called a "comment"
data <- read.csv("https://learndata.net/binge.csv")
View(data)
data$sex_text
data_posts <- read.csv("https://learndata.net/posts.csv")

Key concepts/syntax:

  1. read.csv(): load in a dataset stored in “csv” format

    data <- read.csv("https://learndata.net/binge.csv")
  2. View(): show the data in a spreadsheet view

    View(data)
  3. referring to variables within a dataset: usually when you refer to a variable you also need to indicate the dataset, sometimes you can use $ to connect the name of the dataset to the name of the variable (column)

    data$sex_text
  4. clear out workspace: in RStudio, click the broom icon in the “environment”

  5. To leave a comment in an R script, use #

    # This is a note to myself, called a "comment"
  6. Comment (or uncomment) several lines in a row: in RStudio, select the lines in the R script you want to modify, and then from the drop-down menu select Code > Comment/Uncomment Lines