Comments (3)
@rempsyc this works now:
library(datawizard)
df1 <- data.frame(
id = c(1, 2, 3, 1, 3),
item1 = c(NA, 1, NA, 2, NA),
item2 = c(NA, 1, NA, 2, 3),
item3 = c(NA, 1, 1, 2, 3)
)
dups <- data_duplicated(df1, "id")
dups
#> Row id item1 item2 item3 count_na
#> 1 1 1 NA NA NA 3
#> 4 4 1 2 2 2 0
#> 3 3 3 NA NA 1 2
#> 5 5 3 NA 3 3 1
good.dups <- data_group(dups, "id")
data_filter(good.dups, count_na == min(count_na))
#> Row id item1 item2 item3 count_na
#> 4 4 1 2 2 2 0
#> 5 5 3 NA 3 3 1
Created on 2022-11-07 with reprex v2.0.2
from datawizard.
This works:
library(datawizard)
df1 <- data.frame(
id = c(1, 2, 3, 1, 3),
item1 = c(NA, 1, 1, 2, 3),
item2 = c(NA, 1, 1, 2, 3),
item3 = c(NA, 1, 1, 2, 3)
)
id <- "id"
dups <- data_duplicated(df1, id)
good.dups <- data_group(dups, id)
data_filter(good.dups, count_na == min(count_na))
#> Row id item1 item2 item3 count_na
#> 4 4 1 2 2 2 0
#> 3 3 3 1 1 1 0
#> 5 5 3 3 3 3 0
Created on 2022-11-06 with reprex v2.0.2
from datawizard.
We don't have a data_filter.grouped_df()
so the test above doesn't work if the minimum value in one group is not 0 (it should keep row 5 because it has only one NA
):
library(datawizard)
df1 <- data.frame(
id = c(1, 2, 3, 1, 3),
item1 = c(NA, 1, NA, 2, NA),
item2 = c(NA, 1, NA, 2, 3),
item3 = c(NA, 1, 1, 2, 3)
)
id <- "id"
dups <- data_duplicated(df1, id)
good.dups <- data_group(dups, id)
data_filter(good.dups, count_na == min(count_na))
#> Row id item1 item2 item3 count_na
#> 4 4 1 2 2 2 0
Created on 2022-11-06 with reprex v2.0.2
from datawizard.
Related Issues (20)
- Rename `add_labs()` HOT 5
- `weighted` functions should better deal with `NA` values. HOT 4
- Fix order dependency in unit tests HOT 8
- `standardize()` fails with `Surv` objects when namespaces are used HOT 8
- Problem with datawizard for others packages HOT 1
- tibble-issue
- data_select(): add option to evaluate a function passed to `select` HOT 6
- dw_transformer hits again HOT 19
- `remove_na` vs. `na.rm` HOT 6
- Add select helpers to `data_to_wide` and friends HOT 8
- Plots for describe_distribution() and data_tabulate() HOT 3
- Need better error for `describe_distribution()` with character column
- datawizard versions of separate() and unite() HOT 3
- GHA fails on macOS HOT 3
- Update vignette "Coming from tidyverse"
- Release checklist for 0.8.0 HOT 2
- Select-helper with "." doesn't work as expected? HOT 6
- `standardize()` fails in some cases HOT 4
- Add function for deviation contrasts?
- Rename `rowmean_n()`? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datawizard.