'Disable a range of hours in some day, antd
I want to disable a range of hours from a some day. I don't find any solution until now. I am using datepicker form antd.
Solution 1:[1]
Instead of duplicated
, use n_distinct
(number of distinct elements) after grouping in filter
to keep only groups having single unique element in 'col2'
library(dplyr)
df %>%
group_by(col1) %>%
filter(n_distinct(col2) == 1) %>%
ungroup
-output
# A tibble: 4 × 2
col1 col2
<chr> <dbl>
1 A 0
2 A 0
3 C 1
4 C 1
Or if we want a specific count, create a frequency column with add_count
, then filter
where the n
values are all
2s after grouping by 'col1'
df %>%
add_count(col1, col2) %>%
group_by(col1) %>%
filter(all(n == 2)) %>%
ungroup %>%
select(-n)
Or using base R
subset(df, col1 %in% names(which(rowSums(table(unique(df)) > 0) == 1)))
data
df <- data.frame(col1, col2)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |