findInFiles-shiny {findInFiles} | R Documentation |
Shiny bindings for 'findInFiles'
Description
Output and render functions for using findInFiles
within
Shiny applications and interactive Rmd documents.
Usage
FIFOutput(outputId, width = "100%", height = "400px")
renderFIF(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
output variable to read from |
width , height |
a valid CSS unit (like |
expr |
an expression that generates a ' |
env |
the environment in which to evaluate |
quoted |
logical, whether |
Value
FIFOutput
returns an output element that can be included in a
Shiny UI definition, and renderFIF
returns a
shiny.render.function
object that can be included in a Shiny server
definition.
Examples
library(findInFiles)
library(shiny)
onKeyDown <- HTML(
'function onKeyDown(event) {',
' var key = event.which || event.keyCode;',
' if(key === 13) {',
' Shiny.setInputValue(',
' "pattern", event.target.value, {priority: "event"}',
' );',
' }',
'}'
)
ui <- fluidPage(
tags$head(tags$script(onKeyDown)),
br(),
sidebarLayout(
sidebarPanel(
selectInput(
"ext", "Extension",
choices = c("R", "js", "css")
),
tags$div(
class = "form-group shiny-input-container",
tags$label(
class = "control-label",
"Pattern"
),
tags$input(
type = "text",
class = "form-control",
onkeydown = "onKeyDown(event);",
placeholder = "Press Enter when ready"
)
),
numericInput(
"depth", "Depth (set -1 for unlimited depth)",
value = 0, min = -1, step = 1
),
checkboxInput(
"wholeWord", "Whole word"
),
checkboxInput(
"ignoreCase", "Ignore case"
)
),
mainPanel(
FIFOutput("results")
)
)
)
server <- function(input, output){
output[["results"]] <- renderFIF({
req(input[["pattern"]])
findInFiles(
extensions = isolate(input[["ext"]]),
pattern = input[["pattern"]],
depth = isolate(input[["depth"]]),
wholeWord = isolate(input[["wholeWord"]]),
ignoreCase = isolate(input[["ignoreCase"]])
)
})
}
if(interactive()){
shinyApp(ui, server)
}
[Package findInFiles version 0.5.0 Index]