datawizard icon indicating copy to clipboard operation
datawizard copied to clipboard

test curley braces

Open strengejacke opened this issue 3 years ago • 2 comments

Tries to close #216

But this is not really working yet... Just different attempts to solve that issue.

strengejacke avatar Aug 13 '22 11:08 strengejacke

Codecov Report

Merging #217 (fc86356) into main (224448c) will increase coverage by 0.03%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #217      +/-   ##
==========================================
+ Coverage   84.64%   84.68%   +0.03%     
==========================================
  Files          54       54              
  Lines        3530     3539       +9     
==========================================
+ Hits         2988     2997       +9     
  Misses        542      542              
Impacted Files Coverage Δ
R/data_match.R 97.46% <100.00%> (+0.32%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 13 '22 11:08 codecov-commenter

seems like data_wizard(mtcars, filter = {var} != 0) evaluates the filter argument immediately after function call and sets it to TRUE, so my whole approach here doesn't seem to work.

strengejacke avatar Aug 13 '22 12:08 strengejacke

Can we somehow convert this into a draft, so it won't be merged accidentally?

strengejacke avatar Aug 17 '22 05:08 strengejacke

Done!

IndrajeetPatil avatar Aug 17 '22 05:08 IndrajeetPatil

gluestick might be useful here (but I couldn't make it work so far)

etiennebacher avatar Aug 24 '22 13:08 etiennebacher

Much easier to implement thanks to the previous commits this week. All tests pass locally, and here are some examples. Is this what you had in mind?

When vars are in global environment:

library(datawizard)

var = "mpg"
var2 = "hp"

data_filter(mtcars, "{var} > 30 & {var2} <= 66")
#>                 mpg cyl disp hp drat    wt  qsec vs am gear carb
#> Fiat 128       32.4   4 78.7 66 4.08 2.200 19.47  1  1    4    1
#> Honda Civic    30.4   4 75.7 52 4.93 1.615 18.52  1  1    4    2
#> Toyota Corolla 33.9   4 71.1 65 4.22 1.835 19.90  1  1    4    1
data_filter(mtcars, {var} > 30 & {var2} <= 66)
#>                 mpg cyl disp hp drat    wt  qsec vs am gear carb
#> Fiat 128       32.4   4 78.7 66 4.08 2.200 19.47  1  1    4    1
#> Honda Civic    30.4   4 75.7 52 4.93 1.615 18.52  1  1    4    2
#> Toyota Corolla 33.9   4 71.1 65 4.22 1.835 19.90  1  1    4    1

When vars are passed in a function:

library(datawizard)

foo <- function(var, var2) {
  data_filter(mtcars, filter = {var} > 30 & {var2} <= 66)
}
foo("mpg", "hp")
#>                 mpg cyl disp hp drat    wt  qsec vs am gear carb
#> Fiat 128       32.4   4 78.7 66 4.08 2.200 19.47  1  1    4    1
#> Honda Civic    30.4   4 75.7 52 4.93 1.615 18.52  1  1    4    2
#> Toyota Corolla 33.9   4 71.1 65 4.22 1.835 19.90  1  1    4    1

foo <- function(var, var2) {
  data_filter(mtcars, filter = "{var} > 30 & {var2} <= 66")
}
foo("mpg", "hp")
#>                 mpg cyl disp hp drat    wt  qsec vs am gear carb
#> Fiat 128       32.4   4 78.7 66 4.08 2.200 19.47  1  1    4    1
#> Honda Civic    30.4   4 75.7 52 4.93 1.615 18.52  1  1    4    2
#> Toyota Corolla 33.9   4 71.1 65 4.22 1.835 19.90  1  1    4    1

etiennebacher avatar Sep 02 '22 16:09 etiennebacher

@rempsyc since you opened #216, do you want to check if this PR solves your use cases?

etiennebacher avatar Sep 03 '22 17:09 etiennebacher

Wooah, that's amazing! Commit 2c58497 solved my specific use case for check_outliers by allowing complete character string usage, and this one solves my general use case as described in the PR. It will be way easier to program internally with it. This can close #216 on merge now. Thanks!

rempsyc avatar Sep 03 '22 17:09 rempsyc

@strengejacke Are you ok with the examples above? Or do you have other use cases to test?

etiennebacher avatar Sep 03 '22 18:09 etiennebacher

@strengejacke Are you ok with the examples above? Or do you have other use cases to test?

I had not many particular use cases in mind, your examples look great and are already an improvement to what we currently have. We should probably - if there's such a case - describe what works and what known issue are (i.e. what should users expect no being working at the moment).

strengejacke avatar Sep 03 '22 21:09 strengejacke