import-url {datamods} | R Documentation |
Import data from a URL
Description
Let user paste link to a JSON then import the data.
Usage
import_url_ui(id, title = TRUE)
import_url_server(
id,
btn_show_data = TRUE,
show_data_in = c("popup", "modal"),
trigger_return = c("button", "change"),
return_class = c("data.frame", "data.table", "tbl_df", "raw"),
reset = reactive(NULL)
)
Arguments
id |
Module's ID. |
title |
Module's title, if |
btn_show_data |
Display or not a button to display data in a modal window if import is successful. |
show_data_in |
Where to display data: in a |
trigger_return |
When to update selected data:
|
return_class |
Class of returned data: |
reset |
A |
Value
UI: HTML tags that can be included in shiny's UI
Server: a
list
with three slots:-
status: a
reactive
function returning the status:NULL
,error
orsuccess
. -
name: a
reactive
function returning the name of the imported data ascharacter
. -
data: a
reactive
function returning the importeddata.frame
.
-
Examples
library(shiny)
library(datamods)
ui <- fluidPage(
tags$h3("Import data from URL"),
fluidRow(
column(
width = 4,
import_url_ui("myid")
),
column(
width = 8,
tags$b("Import status:"),
verbatimTextOutput(outputId = "status"),
tags$b("Name:"),
verbatimTextOutput(outputId = "name"),
tags$b("Data:"),
verbatimTextOutput(outputId = "data")
)
)
)
server <- function(input, output, session) {
imported <- import_url_server(
"myid",
btn_show_data = FALSE,
return_class = "raw"
)
output$status <- renderPrint({
imported$status()
})
output$name <- renderPrint({
imported$name()
})
output$data <- renderPrint({
imported$data()
})
}
if (interactive())
shinyApp(ui, server)