I have a data frame that I am passing to a rhandsontable. Let's say it has 10 columns. I have a drop-down that has 3 choices:
- Show columns 1 through 5
- Show columns 1, 5 and 10
- Show columns 6 through 10
Be default, when the rhandsontable loads, it will show all 10 columns. When the use selects one of the three options in the drop-down, I want to hide certain columns using the hot_col(col = col_name, width = 0.5)
For example, if the user selects option 1 - Show columns 1 through 5, hiding columns 6 through 10 would look something like:
rhandsontable(df) %>%
hot_col(col = column_6, width = 0.5) %>%
hot_col(col = column_7, width = 0.5) %>%
hot_col(col = column_8, width = 0.5) %>%
hot_col(col = column_9, width = 0.5) %>%
hot_col(col = column_10, width = 0.5)
I attempted filtering the data set with something like:
df <- if (input$dropdown == "Show columns 1 through 5") {df %>% select(1:5)}
else if (input$dropdown == "Show columns 1, 5 and 10") {df %>% select(1, 5, 10)}
else if (input$dropdown == "Show columns 6 through 10") {df %>% select(6:10)}
else {df %>% select(1:10)}
which works for only showing specific columns, but I have hot_col
rules specific to different columns which bombs because if I have a rule saying that column_6 is of date type, it won't find column_6 if "Show columns 1 through 5" is chosen.
Sorry I don't have a working example, but hope this makes sense. Thanks!