-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
90 lines (65 loc) · 2.03 KB
/
README.Rmd
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# shinyhttr
[![Travis build status](https://travis-ci.org/curso-r/shinyhttr.svg?branch=master)](https://travis-ci.org/curso-r/shinyhttr) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/curso-r/shinyhttr?branch=master&svg=true)](https://ci.appveyor.com/project/curso-r/shinyhttr) [![CRAN status](https://www.r-pkg.org/badges/version/shinyhttr)](https://cran.r-project.org/package=shinyhttr) [![CRAN downloads](https://cranlogs.r-pkg.org/badges/shinyhttr)](https://cran.r-project.org/package=shinyhttr)
The goal of shinyhttr is to integrate `httr::progress` with `shinyWidgets::progressBar`.
In practice, the difference will be
```{r, eval=FALSE}
# from this
httr::GET("http://download.com/large_file.txt",
progress())
# to this
httr::GET("http://download.com/large_file.txt",
progress(session, id = "my_progress_bar1"))
```
![gif_progress_example.gif](man/figures/README-gif_progress_example.gif)
## Installation
From CRAN:
```{r, eval=FALSE}
install.packages("shinyhttr")
```
From github:
```{r, eval=FALSE}
devtools::install_github("curso-r/shinyhttr")
```
## Example
```{r, eval=FALSE}
library(shiny)
library(shinyWidgets)
library(httr)
library(shinyhttr)
ui <- fluidPage(
sidebarLayout(
NULL,
mainPanel(
actionButton('download', 'Download 100MB file...'),
tags$p("see R console to compare both progress bars."),
progressBar(
id = "pb",
value = 0,
title = "",
display_pct = TRUE
)
)
)
)
server <- function(input, output, session) {
observeEvent(input$download, {
GET(
url = "https://speed.hetzner.de/100MB.bin",
shinyhttr::progress(session, id = "pb") # <- the magic happens here. progress() now has session and id args
)
})
}
shinyApp(ui, server)
```