knitr::opts_chunk$set(echo = TRUE) library(rook)
Welcome to the r rook::course_title()
course offered by r toupper(rook::program())
. Because we have more material to cover than we have time together, you will need to do a few things before our first meeting.
WARNING: Do not skim this document. Read it in full.
You must have prior experience writing code in the R programming language.You do not need to be an expert in R. But this course is not an introduction to programming. I will assume you understand the basics of R, such as expressions, functions, conditional statements, loops, etc.
If you are not particularly comfortable writing code in R, or perhaps just generally unsure about your level of preparedness, it is important that you practice writing code in R so that you can get the most out of the course. I created a series of R tutorials for my MSc course "Marketing Analytics." Please download the tutorials, unzip them, and follow along (reading and coding as you go). You do not need to be familiar with all of the material in these tutorials---in fact, we will cover much of this material as part of the class---but at the same time, the material in these tutorials shouldn't be entirely alien to you. A good test is whether you already know everything in Assignment 1, plus how to write basic statements using the if
, for
, and function
statements in R (which are not covered in Assignment 1, but are important for our course). If you know all of that, and can comprehend the material in the later assignments (even if it is unfamiliar), then you are probably in fine shape for the course.
Prior to the first session, you must have the following programs installed on whichever laptop you will bring to the course sessions:
Instructions for each of these follow.
Git is a program for keeping track of changes you make to your code over time.
Install git on your computer if you do not already have it. You can download git from https://git-scm.com/downloads and find detailed installation instructions at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git.
RStudio provides an integrated development environment (IDE) for writing and executing scripts written in R.
Install R on your computer if you do not already have it installed. You can download R from https://cloud.r-project.org/. If you are working on a Windows computer, you should also install RTools.
If you have an older version of R on your computer, now might be a good time to upgrade to the latest version. As of the time of writing, the current version of R is r rversions::r_release()$version
. To see the version on your computer, execute the following code in the R Console (or R Studio if already installed):
version$version.string
Note: Because R has just released a major version, you might want to keep using an older version. I have decided to upgrade to 4.0. But there may be problems for those of us who upgrade, and problems for those of us who do not. Sorry, bad timing...
Install RStudio on your computer if you do not already have it. You can download RStudio from https://www.rstudio.com/products/rstudio/download/. Note that RStudio offers both commercial and free versions; you should install the free version.
Note: Jason is running r paste(unlist(R.version[c('version.string', 'nickname')]), collapse = " ")
and RStudio r rstudioapi::getVersion()
at the time of writing.
Open an R console and execute the following:
install.packages('devtools', dependencies = TRUE) install.packages('pkgbuild', dependencies = TRUE) install.packages('tidyverse', dependencies = TRUE) install.packages('Hmisc', dependencies = TRUE) install.packages('tm', dependencies = NA) # <-- this one is NA instead of TRUE install.packages('rtweet', dependencies = TRUE) install.packages('lda', dependencies = TRUE)
Windows users will want to execute the following R code after they have installed the devtools
package and installed RTools. Open RStudio and type the following into the R Console, then hit Enter.
pkgbuild::setup_rtools()
OS X users may need to install the XCode command-line tool chain, by opening a Terminal window and executing the following command:
xcode-select --install
We will use GitHub to share code and data. Please sign up for an account at https://github.com/ if you do not already have one.
After you have created a GitHub account, you need to do a little bit of configuration:
git config --global user.name "Your Name" git config --global user.email "yourname@example.com"
git credential-osxkeychain git config --global credential.helper osxkeychain
In order to access the Twitter API (Session 3), you need to have the appropriate accounts and security credentials:
rtweet
package. I recommend using Authorization Method #2 (Access token/secret method).The following needs to be done prior to Session 3. Given the short time frame for this course, it is advised that you complete as much of this now as you can (be sure to review the technical material just prior to Session 3, though).
http://some-site.com/show_data?page=1
, then this page: http://some-site.com/show_data?page=2
will probably generate page 2.tm
packagevignette('tm', package = 'tm')
(or https://cran.r-project.org/web/packages/tm/vignettes/tm.pdf if that doesn't work...)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.