Comments (1)
Just dumping here tests that fail in the current version of dplyr::if_else()
. They can probably be made to work with proper casting.
test_that("better factor support (#2197)", {
skip("Currently failing")
test_that("gives proper error messages for factor class (#2197)", {
x <- factor(1:3, labels = letters[1:3])
expect_error(
if_else(x == "a", "b", x),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", 1L, x),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", 1., x),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", TRUE, x),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", Sys.Date(), x),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", x, "b"),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", x, 1L),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", x, 1.),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", x, TRUE),
"asdf",
fixed = TRUE
)
expect_error(
if_else(x == "a", x, Sys.Date()),
"asdf",
fixed = TRUE
)
})
test_that("works with factors as both `true` and `false` (#2197)", {
x <- factor(1:3, labels = letters[1:3])
y <- factor(1:3, labels = letters[c(1, 2, 4)])
expect_equal(if_else(x == "a", x[[2]], x), x[c(2, 2, 3)])
expect_error(
if_else(x == "a", x, y),
"asdf levels in `false` don't match levels in `true`"
)
})
})
from funs.
Related Issues (20)
- Implement is_distinct()? HOT 2
- A na.rm option for cumany? HOT 1
- na.rm argument in lead and lag? HOT 1
- Revisit `dplyr::coalesce` with `across` HOT 7
- Common suffixes and prefixes of vectors HOT 2
- Make sure if_else() cross-references to case_when()
- Add `mode` to vector functions
- Consider `case_when()` variant that uses values HOT 4
- `coalesce()` invariants HOT 1
- `set_intersect()`, `set_union()`, `set_diff()`, and `set_equal()`
- coalesce on a single column (typically with summarize) HOT 3
- Make a website
- Move `master` branch to `main` HOT 1
- Consider `case_when()` variant returning ordered factors HOT 3
- case_when() should preserve names HOT 1
- `between()` should recycle `left` and `right` to the size of `x`
- Should near have a digits argument?
- Accessible helper for run length encoded style groups HOT 1
- vec_equal_na is deprecated
- `min()` and `max()` variants with an `empty` argument
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 funs.