@@ -904,45 +904,49 @@ columnToRowData <- function(data) {
904
904
# '
905
905
# ' @seealso \code{\link{shiny-options}}
906
906
# '
907
- # ' @export
908
907
# ' @examples
908
+ # ' ## Only run examples in interactive R sessions
909
+ # ' if (interactive()) {
910
+ # '
909
911
# ' # uncomment the desired line to experiment with shiny.sanitize.errors
910
912
# ' # options(shiny.sanitize.errors = TRUE)
911
913
# ' # options(shiny.sanitize.errors = FALSE)
912
914
# '
913
- # ' # ui
914
- # ' ui <- shinyUI( fluidPage(
915
+ # ' # Define UI
916
+ # ' ui <- fluidPage(
915
917
# ' textInput('number', 'Enter your favorite number from 1 to 10', '5'),
916
918
# ' textOutput('errorStop'),
917
919
# ' textOutput('errorCustomStop')
918
- # ' ))
920
+ # ' )
919
921
# '
920
- # ' # server
921
- # ' server <- shinyServer( function(input, output) {
922
+ # ' # Server logic
923
+ # ' server <- function(input, output) {
922
924
# ' output$errorStop <- renderText({
923
925
# ' number <- input$number
924
926
# ' if (number %in% 1:10) {
925
927
# ' return(paste('You chose', number, '!'))
926
928
# ' } else {
927
- # ' return( stop(
929
+ # ' stop(
928
930
# ' paste(number, 'is not a number between 1 and 10')
929
- # ' ))
931
+ # ' )
930
932
# ' }
931
933
# ' })
932
934
# ' output$errorCustomStop <- renderText({
933
935
# ' number <- input$number
934
936
# ' if (number %in% 1:10) {
935
937
# ' return(paste('You chose', number, '!'))
936
938
# ' } else {
937
- # ' return( customStop(
939
+ # ' customStop(
938
940
# ' paste(number, 'is not a number between 1 and 10')
939
- # ' ))
941
+ # ' )
940
942
# ' }
941
943
# ' })
942
- # ' })
944
+ # ' }
943
945
# '
944
- # ' # run
945
- # ' if (interactive()) shinyApp(ui = ui, server = server)
946
+ # ' # Complete app with UI and server components
947
+ # ' shinyApp(ui, server)
948
+ # ' }
949
+ # ' @export
946
950
customStop <- function (error , errorClass = character (0 )) {
947
951
if (inherits(error , " error" )) {
948
952
class(error ) <- c(" shiny.custom.error" , errorClass , class(error ))
0 commit comments