Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

56 lines
1.2KB

  1. ---
  2. output: github_document
  3. ---
  4. ```{r setup, include=FALSE}
  5. knitr::opts_chunk$set(eval = FALSE)
  6. github_sha_link <- function(sha) {
  7. glue::glue("[{sha}](https://github.com/gadenbuie/js4shiny-frappeCharts/commit/{sha})")
  8. }
  9. ```
  10. # Building a Shiny Input
  11. In this project,
  12. we're going to create a typing speed app
  13. using a custom Shiny input.
  14. The app will give users typing prompts,
  15. monitor their typing speed,
  16. and use a Frappe Chart line chart
  17. to show their speed over time as they type.
  18. ## Setup a folder for our app inside the frappeCharts package
  19. `r github_sha_link("2188781657884a743c2c4f94dc1fa7755a7de261")`
  20. Create the directory `inst/shiny-input-app` and add `app.R` and `typing.js`.
  21. ```{r}
  22. usethis::use_directory("inst/shiny-input-app")
  23. file.create("inst/shiny-input-app/app.R")
  24. file.create("inst/shiny-input-app/typing.js")
  25. ```
  26. ## Create a basic Shiny app with a typing area
  27. We'll start with typical Shiny inputs.
  28. ```r
  29. library(shiny)
  30. ui <- fluidPage(
  31. textAreaInput("typing", "Type here..."),
  32. verbatimTextOutput("debug")
  33. )
  34. server <- function(input, output, session) {
  35. output$debug <- renderPrint(input$typing)
  36. }
  37. shinyApp(ui, server)
  38. ```
  39. Run this app and type in the box.