mod = lm(new_cases ~ new_tests, data=covid) # linear model
x <- covid$new_tests
y <- covid$new_cases
xax <- list(
title = "New Tests",
titlefont = list(family="Modern Computer Roman"),
range= c(0,3000000))
yax <- list(
title = "New Cases",
titlefont = list(family="Modern Computer Roman"),
range= c(0,400000))
# Plot with linear regression
fig <- plot_ly(x=x, y=y, type="scatter", mode="markers", name="data",
width=800, height=430) %>%
add_lines(x = x, y = fitted(mod), name="fitted") %>%
layout(xaxis = xax, yaxis = yax) %>%
layout(margin=list(l=100, r=50,b=20,t=10))