-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path11-bookmarking.Rmd
More file actions
75 lines (56 loc) · 1.67 KB
/
11-bookmarking.Rmd
File metadata and controls
75 lines (56 loc) · 1.67 KB
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
# Bookmarking
```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = FALSE)
```
## 11.3 Exercises {-}
1.
```{r}
library(shiny)
library(ambient)
ui <- function(request) {
fluidPage(
sidebarLayout(
sidebarPanel(
sliderInput("freq", "frequency", value = 1, min = -2, max = 2, step = 0.01),
selectInput("fractal", "fractal", choices = c("none", "fbm", "billow", "rigid-multi"), selected = "fbm"),
sliderInput("lac", "lacunarity", value = 2, min = 0, max = 5, step = 0.001),
sliderInput("gain", "gain", value = 0.5, min = 0, max = 1, step = 0.001),
bookmarkButton()
),
mainPanel(
plotOutput("fig")
)
)
)
}
server <- function(input, output, session) {
simplex <- reactive({
noise_simplex(dim = c(100, 100),
frequency = input$freq,
fractal = input$fractal,
lacunarity = input$lac,
gain = input$gain)
})
output$fig <- renderPlot({
plot(as.raster(normalise(simplex())))
}, res = 96)
}
shinyApp(ui, server, enableBookmarking = "url")
```
2.
```{r}
library(shiny)
ui <- function(request) {
fluidPage(
fileInput("upload", "Upload CSV file", accept = ".csv", multiple = TRUE),
bookmarkButton()
)
}
server <- function(input, output, session) {
output$head <- renderTable({
head(data(), input$n)
})
}
shinyApp(ui, server, enableBookmarking = "server")
```
- `readRDS("shiny_bookmarks/cf6669ac8bfa4888/input.rds")` gives me a list with one dataframe, upload, with the name, size, type, and datapath of the uploaded datasets. Also, the uploaded datasets are saved inside shiny_bookmarks as `0.csv` and `1.csv`.