stevensanderson, 1 month ago to RegEx I decided to make a blog post out of a problem I worked on a day or two ago and thankfully I was also pointed to another solution from @embiggenData which worked well too. #R #RStats #RProgramming #Data #regex #tidyverse #glue #unglue #tidyr #dplyr Post: https://www.spsanderson.com/steveondata/posts/2024-04-12/ image/png image/png
I decided to make a blog post out of a problem I worked on a day or two ago and thankfully I was also pointed to another solution from @embiggenData which worked well too.
#R #RStats #RProgramming #Data #regex #tidyverse #glue #unglue #tidyr #dplyr
Post: https://www.spsanderson.com/steveondata/posts/2024-04-12/
image/png image/png
stevensanderson, 1 month ago to Glue Some one just reached out looking to extract values from a cell that are produced by #glue from the #tidyverse Example a cell value like 251 (13%) they just want the 251, so I did something like this: library(tidyverse) tibble( value = glue::glue("{11:20} ({1:10}%)"), reged_val = str_extract(value, "\d+(?=\W|$)") |> as.numeric() ) A tibble: 10 × 2 value reged_val <glue> <dbl> 1 11 (1%) 11 Thoughts? #tidyverse #glue #regex #R #RStats
Some one just reached out looking to extract values from a cell that are produced by #glue from the #tidyverse
Example a cell value like 251 (13%) they just want the 251, so I did something like this:
library(tidyverse) tibble( value = glue::glue("{11:20} ({1:10}%)"), reged_val = str_extract(value, "\d+(?=\W|$)") |> as.numeric() )
value reged_val <glue> <dbl> 1 11 (1%) 11
Thoughts?
#tidyverse #glue #regex #R #RStats
embiggenData, 1 month ago @stevensanderson You could also use #unglue https://github.com/moodymudskipper/unglue #rstats
@stevensanderson You could also use #unglue https://github.com/moodymudskipper/unglue
#rstats