forked from stat20/stat20
-
Notifications
You must be signed in to change notification settings - Fork 0
/
license.qmd
99 lines (79 loc) · 3.29 KB
/
license.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: License
toc: false
---
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
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.
[{{< fa brands r-project >}}](https://stat20.datahub.berkeley.edu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fstat20%2Fstat20-assignments&urlpath=rstudio%2F&branch=master)
#### 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**
```{r}
#| warning: false
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**
```{r}
#| warning: false
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
)
```
```{=html}
<iframe width="400" height="400"
src="scatter.html"
></iframe>
```