-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Implement data_seek()
#458
Conversation
btw, this is a slightly modified version of |
Examples: library(datawizard)
# seek variables with "Length" in variable name or labels
seek_variables(iris, "Length")
#> index | column | labels
#> -----------------------------------
#> 1 | Sepal.Length | Sepal.Length
#> 3 | Petal.Length | Petal.Length
# seek variables with "dependency" in names or labels
# column "e42dep" has a label-attribute "elder's dependency"
data(efc)
seek_variables(efc, "dependency")
#> index | column | labels
#> -----------------------------------
#> 3 | e42dep | elder's dependency
# "female" only appears as value label attribute - default search is in
# variable names and labels only, so no match
seek_variables(efc, "female")
#> Can't export table to
#> text
#> , data frame is empty.
# when we seek in all sources, we find the variable "e16sex"
seek_variables(efc, "female", seek = "all")
#> index | column | labels
#> -------------------------------
#> 2 | e16sex | elder's gender
# typo, no match
seek_variables(iris, "Lenght")
#> Can't export table to
#> text
#> , data frame is empty.
# typo, fuzzy match
seek_variables(iris, "Lenght", fuzzy = TRUE)
#> index | column | labels
#> -----------------------------------
#> 1 | Sepal.Length | Sepal.Length
#> 3 | Petal.Length | Petal.Length
# multiple pattern
seek_variables(efc, c("female", "dependency"), seek = "all")
#> index | column | labels
#> -----------------------------------
#> 2 | e16sex | elder's gender
#> 3 | e42dep | elder's dependency Created on 2023-09-12 with reprex v2.0.2 |
This comment was marked as outdated.
This comment was marked as outdated.
Ich mag, especially the integration with labels :) |
As someone that doesn't use labels, I don't expect to use this function over data_find(), but I can see the benefits |
I like this, it would have been useful for me before. How about |
Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>
Co-authored-by: Etienne Bacher <52219252+etiennebacher@users.noreply.github.com>
You could at least use it for factor levels :-) datawizard::data_seek(iris, "setosa", seek = "all")
#> index | column | labels
#> -------------------------
#> 5 | Species | Species Created on 2023-09-12 with reprex v2.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @strengejacke !
@easystats/maintainers What do you think about this function? I find it useful when I see a questionnaire of a data set and am looking for particular variables where the pattern I know are present in value or variable labels.
One problem is the name - this functions tries to find variables, but we already have
data_find()
(andfind_columns() as alias), which work differently and also return the extracted variables -
seek_variables(), on contrast, returns a data frame with a summary of found matches.
find_variables()` is already taken in insight.data_seek()
is currently an alias.