S17 · Chapter 9 · MC 451 Research Methods in Mass Media
Lab session
Deciding where files go is friction, so we skip that decision.
That one line creates the whole folder, already named and already wired together.
Note the v2v:: prefix. It says the function comes from this book’s package, so the package never becomes a hidden assumption.
twitch-portfolio/
├── twitch-portfolio.Rproj
├── _quarto.yml
├── README.md
├── codebook.qmd
├── analysis.qmd
├── data/
└── .Rprofile
You did not decide where anything goes or what to name it, which is the point.
setup() checks that R, the packages this book depends on, and the project environment are all present and agree on versions.
codebook.qmd
We are about to run glimpse(chat), which prints every column.
Line one loads the tidyverse; the next two fetch each table and name it with <-.
The data arrives through a function call, not a file path, which removes a whole category of beginner error. You get the working sample, not the full 2018 collection.
Rows: 35,267
Columns: 5
$ id <int> 89, 551, 1033, 2094, 2803, …
$ channel <chr> "sodapoppin", "xqcow", "forsen", …
$ sender <chr> "madzee", "prometheanow", "spectre155", …
$ message <chr> "???????????????????????", "TriEasy Clap TriEasy…
$ date <dbl> 1542578127023, 1542578135562, 1542578143610, …
glimpse() prints every column, its type, and its first few values.
date is a <dbl> and completely unreadable
Rows: 32,276
Columns: 6
$ channel <chr> "sodapoppin", "xqcow", "forsen", "giantwaffle", …
$ title <chr> "Hello truckers\n44835158804929_2115841973", …
$ game <chr> "Marble It Up!", "Just Chatting", "Artifact", …
$ viewers <int> 27934, 19381, 15300, 4697, 28076, …
$ date <dbl> 1542578200214, 1542578200240, 1542578200273, …
Each row is one snapshot of one stream at one moment.
game n
1 Art 5298
2 Fortnite 3682
3 Just Chatting 2474
4 Hearthstone 2157
6 League of Legends 1952
# ℹ 50 more rows
count() tallies how often each value appears, and sort = TRUE puts the biggest first.
[1] 50
n_distinct(streams$channel) returns the same fiftyCounting is how you check the data is what you were told it is.
Run ?v2v::common_errors for the ones specific to this data.
You should now have:
twitch-portfolio folder, from new_portfolio()v2v::setup() resultcodebook.qmd, versioned and renderedchat and streams loaded, and a glimpse() of eachNothing changed in the data. Looking is all we did.
codebook.qmd and render itglimpse() output on Thursday