import-copypaste: Import data with copy & paste

Description Usage Arguments Value Examples

Description

Let the user copy data from Excel or text file then paste it into a text area to import it.

Usage

1
2
3
4
5
6
7
8
9
import_copypaste_ui(id, title = TRUE)

import_copypaste_server(
  id,
  btn_show_data = TRUE,
  trigger_return = c("button", "change"),
  return_class = c("data.frame", "data.table", "tbl_df"),
  reset = reactive(NULL)
)

Arguments

id

Module's ID.

title

Module's title, if TRUE use the default title, use NULL for no title or a shiny.tag for a custom one.

btn_show_data

Display or not a button to display data in a modal window if import is successful.

trigger_return

When to update selected data: "button" (when user click on button) or "change" (each time user select a dataset in the list).

return_class

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

reset

A reactive function that when triggered resets the data.

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

ui <- fluidPage(
  tags$h3("Import data with copy & paste"),
  fluidRow(
    column(
      width = 4,
      import_copypaste_ui("myid")
    ),
    column(
      width = 8,
      tags$b("Imported data:"),
      verbatimTextOutput(outputId = "status"),
      verbatimTextOutput(outputId = "data")
    )
  )
)

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

  imported <- import_copypaste_server("myid")

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

}

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

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