print("Hello world!")
## [1] "Hello world!"
# load packages
library(tidyverse)
library(broom)
# estimate and print the 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"))
# visualize the relationship
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")
# load packages
library(tidyverse)
library(broom)
# estimate and print the 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 |
# visualize the relationship
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")
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(tidyverse)
library(rtweet)
tmls <- get_timeline(c("MeCookieMonster", "Grover", "elmo", "CountVonCount"), 3000)
ts_plot(group_by(tmls, screen_name), "weeks")
# get_to_sesame_street.R
# Program to retrieve recent tweets from Sesame Street characters
# load packages for data management and Twitter API
library(tidyverse)
library(rtweet)
# retrieve most recent 3000 tweets of Sesame Street characters
tmls <- get_timeline(
user = c("MeCookieMonster", "Grover", "elmo", "CountVonCount"),
n = 3000
)
# group by character and plot weekly tweet frequency
tmls %>%
group_by(screen_name) %>%
ts_plot(by = "weeks")