Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 1.17 KB

README.md

File metadata and controls

60 lines (49 loc) · 1.17 KB

Description

Generates shiny input form input based on a JSON schema structured list. Wraps react-jsonschema-form.

Example

Screenshot of a form with two fields: name and age

library(shiny)
library(shinyjsonschemaform)

schema <- list(
  title = 'My Form',
  type = 'object',
  properties = list(
    name = list(
      title = 'Name',
      type = 'string',
      default = 'Jo'
    ),
    age = list(
      title = 'Age',
      type = 'integer',
      default = 42
    )
  )
)

ui <- fluidPage(
  titlePanel("Simple Form"),
  jsonSchemaFormInput(
      "simpleForm",
      schema = schema
  ),
  verbatimTextOutput('result')
)

server <- function(input, output, session) {
  output$result <- renderText({
    paste(
      input$simpleForm$name,
      input$simpleForm$age,
      sep = '\n'
    )
  })
}

shinyApp(ui, server)

Installation

This package is not yet on CRAN. Install from github:

devtools::install_github('katrinabrock/shinyjsonschemaform', subdir = 'srcR')