Hand-coding: reading each message yourself and recording its value by a written rule. Example: LULW alone is coded 1, a reaction; BIG TREE is coded 0, commentary.
Data Wrangling, Describing, and Inferencing are three parts of one Twitch study
Each part is a worksheet: routine code written, core steps left blank
Under each step: what you should see
Part 0: hand-code thirty messages as reaction or commentary
Inferencing tests the variable you build here
Each worksheet has a risks guide: the traps, and how to check for them
The example study compares gaming and non-gaming chat
It measures that difference through message length
Neither column exists in the loaded table
There is no message length column and no gaming label column
The timestamps are long numbers that no person can read as dates
Whether a channel was gaming sits in the other table, which is not yet linked
Your own data will probably lack some columns your question needs; the same steps build them
Variables, Revisited
Variable: something about a case that can change from one case to the next, where a case is one thing you study, such as one chat message.
The example study’s two variables are the gaming label and message length
An analysis-ready table gives each variable its own column and each case its own row
Data Wrangling, Defined
Data wrangling: getting data into a form you can analyze, by tidying it (one row per case, one column per variable) and transforming it (keeping rows, adding columns, summarizing, joining tables). Example: turning the chat table’s timestamp digits into dates and adding a message length column.
It is rarely described in the published paper, and it is most of the work
Each step is small and technical
Together, the steps build the table every result depends on
Packages and the Tidyverse
Package: a bundle of functions, data, and help pages that adds to what R can do on its own. Example: the course package, v2v, adds the example Twitch data and a chart theme.
Tidyverse: a collection of R packages for data science that share one design and are built to work together. Example: library(tidyverse) loads its core packages at once, including dplyr for tables and ggplot2 for charts.
dplyr, one of those packages, supplies today’s five verbs
The Verbs: filter() and select()
chat %>%filter(channel =="bobross")
filter() keeps the rows that meet a condition and drops the rest
Here it keeps only Bob Ross’s messages
chat %>%select(channel, sender, message)
select() keeps or drops columns
Here it narrows five columns to three
The Verbs: mutate(), arrange(), group_by(), and summarize()
mutate() adds a column or changes one, computed from other columns
arrange() reorders the rows by a column’s values
group_by() with summarize() collapses many rows into one row per group
That pair is how you get one number per channel, such as its message count
Pipe (%>%): read it as “and then”; it hands the result of one line to the next. Example: chat %>% filter(channel == "bobross") takes the chat table, then keeps Bob Ross’s messages.
Each verb takes a data frame (R’s name for a table) and returns a data frame
That shared design is what lets %>% string them together
One verb’s output is the next verb’s input
A pipeline reads in order: take the data, then do this, then do that
Today and Thursday, four transformations built this way turn the example chat table into the table the study needs
One emote name is 8 characters, the row of question marks is 23, and a block of repeated pasted text is 441
message_length is a ratio variable: it has a true zero and equal intervals, so it is safe to average
Common Errors Today
Every message is dated around the year 50,850: you converted by hand and forgot / 1000
could not find function "str_length": you have not run library(tidyverse)
object 'message_length' not found: R has nothing by that name yet (R calls anything you have named an object): you never assigned the result back to chat
<- is what makes a change stick
unexpected '=': usually a single = where == belongs
Any Other Error
Select the error R printed in the terminal, then press Ctrl+C (Cmd+C on a Mac) to copy it
Press Ctrl+Shift+P (Cmd+Shift+P on a Mac) and run AURA: Explain an R error: the copied error is filled in for you
What Explain an R Error Shows
The explanation opens beside your script: why the error happens, then what to do
Checkpoint
You should now have:
A chat object and a streams object, each with a working ts column, typed <dttm>
A message_length column on chat, typed <int> (whole numbers)
Output showing dates in November 2018
Today’s steps filled in your worksheet, not typed into the console (the R terminal, where typed lines are not saved)
Any step the R Companion wrote (AURA: Write R code, R2 Data) sits in the worksheet with its comments
Still missing: the gaming label. That is Thursday.
Coding in the Data Viewer
AURA: Open the data viewer on data/coding-form.csv, then Add coding column
Type each code in the new column; the line under the buttons confirms each save
Before Thursday
Code your thirty messages in the worksheet’s Part 0, in a spreadsheet or in the R Companion’s data viewer