0

My all columns contains parameters names like: "all_application", "all_phones" "all_send_forms" It doesn't look nicely in shiny tables. How do You deal with it? I would like to change it to more human names with spaces.

aynber
  • 22,380
  • 8
  • 50
  • 63
brtk
  • 107
  • 7
  • hi, please include a [reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). It will be easier to see what you want – bretauv Apr 10 '20 at 12:31

1 Answers1

1

I usually just rename my columns as a last step in shiny before passing a dataframe to an output render:

 library(tidyverse)

df <- tibble (all_columns = 1:3,
              all_phones = c("a", "b", "c"))

df_nice_names <- df %>%
  rename("All Columns" = all_columns,
          "All Phones" = all_phones)

# A tibble: 3 x 2
  `All Columns` `All Phones`
          <int> <chr>       
1             1 a           
2             2 b           
3             3 c   

Shiny App:

library(shiny)


ui <- fluidPage(


    titlePanel(""),


    sidebarLayout(
        sidebarPanel(

        ),


        mainPanel(
           tableOutput("table")
        )
    )
)


server <- function(input, output) {

    output$table <- renderTable({
        library(tidyverse)

        df <- tibble (all_columns = 1:3,
                      all_phones = c("a", "b", "c"))

        df_nice_names <- df %>%
            rename("All Columns" = all_columns,
                   "All Phones" = all_phones)
    })

}

# Run the application 
shinyApp(ui = ui, server = server)
bs93
  • 1,236
  • 6
  • 10