Setting width of renderPrint area

Hi,

How can one set the width of the print area created by renderPrint and displayed using verbatimTextOutput? The width option of renderPrint seems to do nothing, as modifying the options()$width value.

Any suggestions is greatly appreciated.

Thanks

require(shiny)

# Global variables can go here
df <- as.data.frame(matrix(1:20, nrow = 1))
names(df) <- paste0(V, 1:ncol(df))

# Define the UI
ui <- bootstrapPage(
  numericInput(
    inputId = 'width',
    label = 'Width',
    value = 100,
    min = 50,
    max = 400,
    step = 10
  ),
  verbatimTextOutput('printArea')
)


# Define the server code
server <- function(input, output) {
  
  output$printArea <- renderPrint(
    {
      #options(width = input$width)
      cat(sprintf('Width: %s\n\n', input$width))
      summary(df)
    },
    width = input$width
  )
  
}

# Return a Shiny app object
shinyApp(ui = ui, server = server,options = list(launch.browser = TRUE))

My current configuration:

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.3

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.5.0

loaded via a namespace (and not attached):
 [1] compiler_3.6.3  fastmap_1.0.1   magrittr_1.5    R6_2.4.1        promises_1.1.0  later_1.0.0     htmltools_0.5.0 tools_3.6.3    
 [9] Rcpp_1.0.4.6    jsonlite_1.6.1  digest_0.6.25   xtable_1.8-4    httpuv_1.5.4    mime_0.9        rlang_0.4.6 

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.