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

Standardize: unnecessary argument #30

Closed
DominiqueMakowski opened this issue Nov 4, 2021 · 2 comments
Closed

Standardize: unnecessary argument #30

DominiqueMakowski opened this issue Nov 4, 2021 · 2 comments

Comments

@DominiqueMakowski
Copy link
Member

DominiqueMakowski commented Nov 4, 2021

Just noticed this:

datawizard/R/standardize.R

Lines 186 to 187 in 5ab5cdc

append = FALSE,
suffix = "_z",

It seems like we could have just had suffix=NULL by default and if suffix="z_" then it's added, no need for a toggle argument append on top of that as it makes it more confusing and weighs the API down

I can make a quick fix providing it won't break a thousand things ^^

@strengejacke
Copy link
Member

append adds the standardized variables to the input data frame (or not), it has nothing to do with the suffix.

d <- iris[1:5, 1:4]
datawizard::standardise(d)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1    1.1573828   0.8499342     0.000000         0.2
#> 2    0.1928971  -1.0817344     0.000000         0.2
#> 3   -0.7715885  -0.3090670    -1.414214         0.2
#> 4   -1.2538313  -0.6954007     1.414214         0.2
#> 5    0.6751400   1.2362679     0.000000         0.2
datawizard::standardise(d, append = TRUE)
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Sepal.Length_z
#> 1          5.1         3.5          1.4         0.2      1.1573828
#> 2          4.9         3.0          1.4         0.2      0.1928971
#> 3          4.7         3.2          1.3         0.2     -0.7715885
#> 4          4.6         3.1          1.5         0.2     -1.2538313
#> 5          5.0         3.6          1.4         0.2      0.6751400
#>   Sepal.Width_z Petal.Length_z Petal.Width_z
#> 1     0.8499342       0.000000           0.2
#> 2    -1.0817344       0.000000           0.2
#> 3    -0.3090670      -1.414214           0.2
#> 4    -0.6954007       1.414214           0.2
#> 5     1.2362679       0.000000           0.2

Created on 2021-11-04 by the reprex package (v2.0.1)

@strengejacke
Copy link
Member

It's rather that suffix doesn't work when data is not appended:

d <- iris[1:5, 1:4]
datawizard::standardise(d, suffix = "_z")
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1    1.1573828   0.8499342     0.000000         0.2
#> 2    0.1928971  -1.0817344     0.000000         0.2
#> 3   -0.7715885  -0.3090670    -1.414214         0.2
#> 4   -1.2538313  -0.6954007     1.414214         0.2
#> 5    0.6751400   1.2362679     0.000000         0.2

Created on 2021-11-04 by the reprex package (v2.0.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants