recogito-shiny | R Documentation |
Output and render functions for using recogito within Shiny applications and interactive Rmd documents.
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)
outputId |
output variable to read from |
width, height |
Must be a valid CSS unit (like |
expr |
An expression that generates a recogito |
env |
The environment in which to evaluate |
quoted |
Is |
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
)
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.