MACS 30500
University of Chicago
print("Hello world!")
## [1] "Hello world!"
# linear model
lm(hwy ~ displ, data = mpg) %>%
tidy %>%
mutate(term = c("Intercept", "Engine displacement (in liters)")) %>%
knitr::kable(digits = 2,
col.names = c("Variable", "Estimate", "Standard Error",
"T-statistic", "P-Value"))
Variable | Estimate | Standard Error | T-statistic | P-Value |
---|---|---|---|---|
Intercept | 35.70 | 0.72 | 49.55 | 0 |
Engine displacement (in liters) | -3.53 | 0.19 | -18.15 | 0 |
# visualization
ggplot(data = mpg, aes(displ, hwy)) +
geom_point(aes(color = class)) +
geom_smooth(method = "lm", se = FALSE, color = "black", alpha = .25) +
labs(x = "Engine displacement (in liters)",
y = "Highway miles per gallon",
color = "Car type") +
theme_bw(base_size = 16)
15 min rule: when stuck, you HAVE to try on your own for 15 min; after 15 min, you HAVE to ask for help.- Brain AMA pic.twitter.com/MS7FnjXoGH
— Rachel Thomas (@math_rachel) August 14, 2016
If you don’t understand what the program is doing and are not prepared to explain it in detail, you should not submit it.
A series of instructions that specifies how to perform a computation
Write a report analyzing the relationship between ice cream consumption and crime rates in Chicago
analysis-1.r
analysis-2.r
analysis-3.r
library(twitteR)
source("keys.R")
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
data <- userTimeline("realdonaldtrump", n = 1000)
data2 <- twListToDF(data)
write.csv(data2, "data2.csv")
# get_tweets.R
# Program to get Donald Trump tweets using Twitter API
# access Twitter API functions
library(twitteR)
# setup API authentication
source("keys.R") # store keys privately in separate file
setup_twitter_oauth(consumer_key,
consumer_secret,
access_token,
access_secret)
# get 1000 most recent tweets
username <- "realdonaldtrump"
tweets <- userTimeline(username, n = 1000)
# convert to data frame
tweets_df <- twListToDF(tweets)
# write to disk
write.csv(tweets_df, "tweets_trump.csv")