Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Factor Variable with Single Level Breaks in Shiny #12

Closed
JonP-16 opened this issue Jul 3, 2019 · 1 comment
Closed

Adding Factor Variable with Single Level Breaks in Shiny #12

JonP-16 opened this issue Jul 3, 2019 · 1 comment
Assignees
Labels

Comments

@JonP-16
Copy link

JonP-16 commented Jul 3, 2019

I'm creating a Shiny app where users can filter their data and I display it in your lineup table (Thanks for making it!). Unfortunately, if the user wants to filter one of the factor variables to single level, that column and any column to the right in the table does not show up. Below I have an example where new_var is a factor with a single level and thus, the entire table doesn't show up. I think this is a bug since I didn't find anything in the help files about this.

library(shiny)
library(lineupjs)
library(dplyr)

ui <- fluidPage(
  fluidRow(
    lineupOutput("lineup1")
  )
)

server <- function(input, output) {
  output$lineup1 <- renderLineup({
    temp1 = iris %>% mutate(new_var = "test") # works because it's a character
    temp2 = iris %>% mutate(new_var = as.factor("test")) # does not work
    temp3 = iris %>% filter(Species == 'virginica') # works - don't know why it does but temp2 doesn't
   
    lineup(temp2, width = "100%")
  })
}

# Run the application
shinyApp(ui = ui, server = server)
@sgratzl sgratzl added the bug label Jul 4, 2019
@sgratzl sgratzl self-assigned this Jul 4, 2019
@sgratzl sgratzl closed this as completed in 2dbb87c Jul 4, 2019
@sgratzl
Copy link
Member

sgratzl commented Jul 4, 2019

thx for reporting. R Shiny automatically transforms arrays with just one element into a primitive value. In your case the array ["test"] was converted to "test" which is not a valid list of categories. I added a fix that is now part of the master branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants