License

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.

The source materials for the curriculum for this course and the software that builds this website are all available under at:

https://github.com/stat20/course-materials

Testing zone

The content below are experimental tests for future functionality.

Distributing assignments via nbgitpuller

Below is a test of a new method of distributing assignments. Click the R logo to synchronize your RStudio with the most recent assignments.

Publishing plotly plots via GHA

The code below can produce an interactive plotly plot when rendered locally but fails when rendered via GHA.

Method 1: Rendering directly from code cell

library(tidyverse)
zagat <- read_csv("https://www.dropbox.com/s/c797oanmvdzjegt/zagat.csv?dl=1")

library(plotly)
library(reshape2)

m1 <- lm(price ~ food + decor, data = zagat)
grid_points <- 30
axis_x <- seq(min(zagat$food), 
              max(zagat$food),
              length.out = grid_points)
axis_y <- seq(min(zagat$decor), 
              max(zagat$decor),
              length.out = grid_points)
zagat_plane <- expand.grid(food = axis_x, 
                         decor = axis_y, 
                         KEEP.OUT.ATTRS = F)
zagat_plane$price <- predict.lm(m1, newdata = zagat_plane)
z <- acast(zagat_plane, food ~ decor, value.var = "price")
p <- plot_ly(zagat, x = ~food, y = ~decor, z = ~price, showlegend=FALSE) %>%
  add_markers(marker = list(size = 5,
                            opacity = .6,
                            color = "steelblue"),
              name = ~restaurant) %>%
  config(displayModeBar = FALSE)
p

Method 2: Saving output as html file then serving in an iframe

library(tidyverse)
zagat <- read_csv("https://www.dropbox.com/s/c797oanmvdzjegt/zagat.csv?dl=1")

library(plotly)
library(reshape2)

m1 <- lm(price ~ food + decor, data = zagat)
grid_points <- 30
axis_x <- seq(min(zagat$food), 
              max(zagat$food),
              length.out = grid_points)
axis_y <- seq(min(zagat$decor), 
              max(zagat$decor),
              length.out = grid_points)
zagat_plane <- expand.grid(food = axis_x, 
                         decor = axis_y, 
                         KEEP.OUT.ATTRS = F)
zagat_plane$price <- predict.lm(m1, newdata = zagat_plane)
z <- acast(zagat_plane, food ~ decor, value.var = "price")
p <- plot_ly(zagat, x = ~food, y = ~decor, z = ~price, showlegend=FALSE) %>%
  add_markers(marker = list(size = 5,
                            opacity = .6,
                            color = "steelblue"),
              name = ~restaurant) %>%
  config(displayModeBar = FALSE)
p %>%
  htmlwidgets::saveWidget(
    "scatter.html",
    selfcontained = TRUE
  )