import-modal: Get all import functions in a Modal

Description Usage Arguments Value Examples

Description

Let the user choose a method of his choice to import data

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import_ui(id, from = c("env", "file", "copypaste", "googlesheets"))

import_server(
  id,
  validation_opts = NULL,
  allowed_status = c("OK", "Failed", "Error"),
  return_class = c("data.frame", "data.table", "tbl_df")
)

import_modal(id, from, title = "Import data", size = "l")

Arguments

id

Module's id

from

The import_ui & server to use, i.e. the method. There are 4 options to choose from. ("env", "file", "copypaste", "googlesheets")

validation_opts

list of arguments passed to validation_server.

allowed_status

Vector of statuses allowed to confirm dataset imported, if you want that all validation rules are successful before importing data use allowed_status = "OK".

return_class

Class of returned data: data.frame, data.table or tbl_df (tibble).

title

Modal window title.

size

Modal window size, default to "l" (large).

Value

Examples

 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
library(shiny)
library(datamods)

ui <- fluidPage(
  fluidRow(
    column(
      width = 4,
      checkboxGroupInput(
        inputId = "from",
        label = "From",
        choices = c("env", "file", "copypaste", "googlesheets"),
        selected = c("file", "copypaste")
      ),
      actionButton("launch_modal", "Launch modal window")
    ),
    column(
      width = 8,
      tags$b("Imported data:"),
      verbatimTextOutput(outputId = "name"),
      verbatimTextOutput(outputId = "data")
    )
  )
)

server <- function(input, output, session) {

  observeEvent(input$launch_modal, {
    req(input$from)
    import_modal(
      id = "myid",
      from = input$from,
      title = "Import data to be used in application"
    )
  })

  imported <- import_server("myid", return_class = "tbl_df")

  output$name <- renderPrint({
    req(imported$name())
    imported$name()
  })

  output$data <- renderPrint({
    req(imported$data())
    imported$data()
  })
}

if (interactive())
  shinyApp(ui, server)

datamods documentation built on July 2, 2021, 5:07 p.m.