-
Notifications
You must be signed in to change notification settings - Fork 3
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
Begging for feedback! #20
Comments
Love the package! One thing that would be cool would be to have a shortcut to ignore whitespace. Here's an example: library(unglue)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(stringr)
# common string format
example_text <- c("20-20-32 1 file_name", "20-20-33 23 file_name2")
cat(example_text[1], example_text[2], sep = '\n')
#> 20-20-32 1 file_name
#> 20-20-33 23 file_name2
# how I do it today
example_text %>%
unglue_data("{date} {size} {file}") %>%
mutate(unglued = unglue(str_trim(file), "{bytes} {name}")) %>%
tidyr::unnest(unglued)
#> # A tibble: 2 x 5
#> date size file bytes name
#> <chr> <lgl> <chr> <int> <chr>
#> 1 20-20-32 NA " 1 file_name" 1 file_name
#> 2 20-20-33 NA " 23 file_name2" 23 file_name2
# I'd like to do this to get the same answer
example_text %>%
unglue_data("{date} {size} {file}")
#> date size file
#> 1 20-20-32 NA 1 file_name
#> 2 20-20-33 NA 23 file_name2 Created on 2020-02-19 by the reprex package (v0.3.0) |
Hi @tmastny , thanks for the kind words! I believe you can get what you want by running :
Where the I understand that there might be value in something more obvious though but I can't make it the default, I'll think about it as I don't have any idea now, |
Thanks for the tip! I definitely agree, ignoring whitespace shouldn't be the default. I was thinking like a function argument, I was originally thinking something along the lines of this issue: #19 One reason I like unglue so much is that it is intuitive and I can figure out the parsing without any regex. |
I had forgotten this wild experiment in #19! I was hesitant to implement this as I've tried to make unglue "tidy compliant" and I don't think they'd approve this weird feature. Do you feel that the following is intuitive ?
Or is it just weird and mildly interesting ? :)
Note that you can also do (still using regex):
To avoid regex, if it's a task common enough, we can define a helper function
Or use
Actually the latter is now my official recommended solution for this case if you use tidyverse tools in your workflow :). |
I would like to use it with a tidyverse tibble in a simple way. For example, let's say we start with this tibble: Then I would like to run a command like this: To get a tibble like this: Maybe this is already simple to do, but I have a hard time understanding how from the vignette. |
Hi @ymer, I believe you want |
leaving this pinned, feedback is always welcome, but closing, please open new issues! |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary. |
I received positive comments when I released the package but it's REALLY HARD to get specific feedback, so If you end up here, have 5 min to spare, and would like to make me happy, please share :
The text was updated successfully, but these errors were encountered: