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:
read.csv(): load in a dataset stored in “csv” formatdata <- read.csv("https://learndata.net/binge.csv")View(): show the data in a spreadsheet viewView(data)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_textclear out workspace: in RStudio, click the broom icon in the “environment”
To leave a comment in an R script, use
## This is a note to myself, called a "comment"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