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

Selection of multiple levels #1105

Open
Watjoa opened this issue Dec 19, 2023 · 2 comments
Open

Selection of multiple levels #1105

Watjoa opened this issue Dec 19, 2023 · 2 comments
Labels

Comments

@Watjoa
Copy link

Watjoa commented Dec 19, 2023

Hi people of DT

I have a question regarding the following issue:

In filtering a factor variable, we are currently able to click on the different levels by which all rows including one of our selections are displayed. For instance, I click on A and B, by which all rows having A or B are displayed.

But, what if I have multiple levels into these cells? For instance, a row includes both A and B (A, B) or both B and C (B, C). Does the DT team know how all unique values could be displayed in the filtering (A, B, C) but all rows including the selection are displayed as a consequence?

As an example: I have 3 rows, with following cells in the column 'category': A - A, B - B, C
In the filtering, I am able to select A or B or C. When I click on A, the first 2 rows are displayed. When I add B to this selection, all rows are displayed.

Thanks in advance!

@yihui
Copy link
Member

yihui commented Dec 19, 2023

In this case, the column is no longer a factor, because a factor level can't have multiple values. For example, the string "A, B" is a level itself, instead of a level containing two levels.

I think you should make the column a character vector instead of factor. Then use regular expressions to search (e.g., A|B means matching either A or B). Here is an example: https://rstudio.github.io/DT/007-search.html

@yihui yihui added the question label Dec 19, 2023
@stla
Copy link
Collaborator

stla commented Dec 19, 2023

Or use the SearchBuilder extension (only with server=FALSE in Shiny).

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

3 participants