recogito-shiny {recogito}R Documentation

Shiny bindings for recogito

Description

Output and render functions for using recogito within Shiny applications and interactive Rmd documents.

Usage

recogitoOutput(outputId, width = "100%", height = "400px")

renderRecogito(expr, env = parent.frame(), quoted = FALSE)

recogitotagsonlyOutput(outputId, width = "100%", height = "400px")

renderRecogitotagsonly(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates a recogito

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote())? This is useful if you want to save an expression in a variable.

Value

An output element for use in a Shiny user interface.
Consisting of a div of class plaintext which contains an optional toggle button to switch between annotation / relation mode (id: outputId-toggle) and the html-widget (id: outputId)

Examples

if(interactive() && require(shiny)){

##
## Tagging only, no relations
##
library(shiny)
library(recogito)
txt <- "Josh went to the bakery in Brussels.\nWhat an adventure!"
ui <- fluidPage(tags$h3("Provide some text to annotate"),
                textAreaInput(inputId = "ui_text", label = "Provide some text", value = txt),
                tags$h3("Annotation area"),
                recogitotagsonlyOutput(outputId = "annotation_text"),
                tags$hr(),
                tags$h3("Results"),
                verbatimTextOutput(outputId = "annotation_result"))
server <- function(input, output) {
  output$annotation_text <- renderRecogitotagsonly({
    recogito("annotations", text = input$ui_text, tags = c("LOCATION", "TIME", "PERSON"))
  })
  output$annotation_result <- renderPrint({
    read_recogito(input$annotations)
  })
}
shinyApp(ui, server)

##
## Tagging and relations
##
library(shiny)
library(recogito)
txt <- "Josh went to the bakery in Brussels.\nWhat an adventure!"
ui <- fluidPage(tags$h3("Provide some text to annotate"),
                textAreaInput(inputId = "ui_text", label = "Provide some text", value = txt),
                tags$h3("Annotation area"),
                recogitoOutput(outputId = "annotation_text"),
                tags$hr(),
                tags$h3("Results"),
                verbatimTextOutput(outputId = "annotation_result"))
server <- function(input, output) {
  output$annotation_text <- renderRecogito({
    recogito("annotations", text = input$ui_text, tags = c("LOCATION", "TIME", "PERSON"))
  })
  output$annotation_result <- renderPrint({
    read_recogito(input$annotations)
  })
}
shinyApp(ui, server)

}

recogitoOutput(outputId = "annotation_text")
recogitotagsonlyOutput(outputId = "annotation_text")

[Package recogito version 0.2.1 Index]