diff --git a/dev/CODE_OF_CONDUCT.html b/dev/CODE_OF_CONDUCT.html index 0b8da41..58ed7b1 100644 --- a/dev/CODE_OF_CONDUCT.html +++ b/dev/CODE_OF_CONDUCT.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/CONTRIBUTING.html b/dev/CONTRIBUTING.html index dc966d5..ff3df78 100644 --- a/dev/CONTRIBUTING.html +++ b/dev/CONTRIBUTING.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/LICENSE-text.html b/dev/LICENSE-text.html index b15143a..df3e808 100644 --- a/dev/LICENSE-text.html +++ b/dev/LICENSE-text.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/LICENSE.html b/dev/LICENSE.html index 407929a..4651460 100644 --- a/dev/LICENSE.html +++ b/dev/LICENSE.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/MAINTENANCE.html b/dev/MAINTENANCE.html index a9a84fa..fa529e8 100644 --- a/dev/MAINTENANCE.html +++ b/dev/MAINTENANCE.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/SUPPORT.html b/dev/SUPPORT.html index 3d43a78..12c0897 100644 --- a/dev/SUPPORT.html +++ b/dev/SUPPORT.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/articles/engines.html b/dev/articles/engines.html index 9cdf8c9..17d78b1 100644 --- a/dev/articles/engines.html +++ b/dev/articles/engines.html @@ -42,7 +42,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/articles/index.html b/dev/articles/index.html index d7f249a..9125c64 100644 --- a/dev/articles/index.html +++ b/dev/articles/index.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/articles/speed.html b/dev/articles/speed.html index ed2f67c..54e06aa 100644 --- a/dev/articles/speed.html +++ b/dev/articles/speed.html @@ -42,7 +42,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 @@ -166,11 +166,11 @@ Simple concatenation#> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> -#> 1 sprintf 711.07ns 811.07ns 1067910. 0B 107. -#> 2 paste0 1.44µs 1.57µs 560352. 0B 0 -#> 3 glue 98.51µs 106.49µs 8494. 139.66KB 30.0 -#> 4 gstring 227.21µs 260.5µs 3293. 2.45MB 15.0 -#> 5 rprintf 277.12µs 310.56µs 2776. 78.14KB 8.24 +#> 1 sprintf 761.12ns 872.07ns 1086458. 0B 0 +#> 2 paste0 1.49µs 1.65µs 566993. 0B 56.7 +#> 3 glue 101.3µs 107.23µs 9050. 139.63KB 30.2 +#> 4 gstring 227.02µs 238.4µs 4053. 2.45MB 19.2 +#> 5 rprintf 279.6µs 287.26µs 3422. 78.14KB 10.4 # plotting function defined in a hidden chunk plot_comparison(simple) @@ -213,11 +213,11 @@ Vectorized performance#> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl> -#> 1 paste0 8.34ms 8.37ms 119. 781.3KB 4.17 -#> 2 sprintf 9.6ms 9.87ms 101. 781.3KB 4.14 -#> 3 gstring 11.2ms 11.34ms 85.4 1.53MB 4.17 -#> 4 glue 12.81ms 13.32ms 71.1 2.29MB 6.46 -#> 5 rprintf 27.55ms 27.78ms 36.0 3.05MB 4.50 +#> 1 paste0 8.33ms 8.35ms 119. 781.3KB 4.18 +#> 2 sprintf 9.57ms 9.86ms 101. 781.3KB 4.23 +#> 3 gstring 11.25ms 11.35ms 88.0 1.53MB 6.44 +#> 4 glue 12.7ms 13.28ms 73.6 2.29MB 6.49 +#> 5 rprintf 28.06ms 28.39ms 35.2 3.05MB 4.40 # plotting function defined in a hidden chunk plot_comparison(vectorized) diff --git a/dev/articles/speed_files/figure-html/unnamed-chunk-2-1.png b/dev/articles/speed_files/figure-html/unnamed-chunk-2-1.png index 4746566..da2678e 100644 Binary files a/dev/articles/speed_files/figure-html/unnamed-chunk-2-1.png and b/dev/articles/speed_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/dev/articles/speed_files/figure-html/unnamed-chunk-3-1.png b/dev/articles/speed_files/figure-html/unnamed-chunk-3-1.png index aea47db..f852280 100644 Binary files a/dev/articles/speed_files/figure-html/unnamed-chunk-3-1.png and b/dev/articles/speed_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/dev/articles/transformers.html b/dev/articles/transformers.html index d734f50..3ec7484 100644 --- a/dev/articles/transformers.html +++ b/dev/articles/transformers.html @@ -42,7 +42,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/authors.html b/dev/authors.html index 6395ce2..340c76f 100644 --- a/dev/authors.html +++ b/dev/authors.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 @@ -84,15 +84,15 @@ Authors Citation Source: DESCRIPTION - Hester J, Bryan J (2023). + Hester J, Bryan J (2024). glue: Interpreted String Literals. -R package version 1.6.2.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/. +R package version 1.7.0.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/. @Manual{, title = {glue: Interpreted String Literals}, author = {Jim Hester and Jennifer Bryan}, - year = {2023}, - note = {R package version 1.6.2.9000, https://github.com/tidyverse/glue}, + year = {2024}, + note = {R package version 1.7.0.9000, https://github.com/tidyverse/glue}, url = {https://glue.tidyverse.org/}, } diff --git a/dev/index.html b/dev/index.html index 5a4241a..e844afc 100644 --- a/dev/index.html +++ b/dev/index.html @@ -52,7 +52,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/news/index.html b/dev/news/index.html index 769fcc6..13f5de9 100644 --- a/dev/news/index.html +++ b/dev/news/index.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 @@ -66,6 +66,9 @@ Releases glue (development version) + + +glue 1.7.0CRAN release: 2024-01-09 If rlang is installed, glue will generate more informative errors if an interpolated expression either can’t be parsed or fails to evaluate (#229). + now works in more situations, and gives errors when one side isn’t a character vector. It no longer automatically applies glue interpolation to a non-glue input, if there is one. You’ll need to do that yourself (#286). glue_collapse(character()) (and hence glue_sql_collapse(character())) now return "", so that they always return a single string (#88). diff --git a/dev/pkgdown.yml b/dev/pkgdown.yml index eeaaeda..96ee978 100644 --- a/dev/pkgdown.yml +++ b/dev/pkgdown.yml @@ -5,7 +5,7 @@ articles: speed: speed.html engines: engines.html transformers: transformers.html -last_built: 2023-12-22T17:36Z +last_built: 2024-01-10T00:32Z urls: reference: https://glue.tidyverse.org/reference article: https://glue.tidyverse.org/articles diff --git a/dev/reference/as_glue.html b/dev/reference/as_glue.html index 4d232a0..2629aae 100644 --- a/dev/reference/as_glue.html +++ b/dev/reference/as_glue.html @@ -22,7 +22,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue-deprecated.html b/dev/reference/glue-deprecated.html index c63e577..aca81df 100644 --- a/dev/reference/glue-deprecated.html +++ b/dev/reference/glue-deprecated.html @@ -18,7 +18,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue.html b/dev/reference/glue.html index 8c3b74a..e97a207 100644 --- a/dev/reference/glue.html +++ b/dev/reference/glue.html @@ -20,7 +20,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue_col.html b/dev/reference/glue_col.html index 5c99c60..b2432b9 100644 --- a/dev/reference/glue_col.html +++ b/dev/reference/glue_col.html @@ -38,7 +38,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue_collapse.html b/dev/reference/glue_collapse.html index b3b1c45..82d0a9c 100644 --- a/dev/reference/glue_collapse.html +++ b/dev/reference/glue_collapse.html @@ -20,7 +20,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue_safe.html b/dev/reference/glue_safe.html index 3764799..29ed349 100644 --- a/dev/reference/glue_safe.html +++ b/dev/reference/glue_safe.html @@ -24,7 +24,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/glue_sql.html b/dev/reference/glue_sql.html index ae0005e..bcb847e 100644 --- a/dev/reference/glue_sql.html +++ b/dev/reference/glue_sql.html @@ -48,7 +48,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/identity_transformer.html b/dev/reference/identity_transformer.html index e5cb040..2a50e10 100644 --- a/dev/reference/identity_transformer.html +++ b/dev/reference/identity_transformer.html @@ -18,7 +18,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/index.html b/dev/reference/index.html index c2a041b..c811c84 100644 --- a/dev/reference/index.html +++ b/dev/reference/index.html @@ -16,7 +16,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/quoting.html b/dev/reference/quoting.html index 21f7ee7..213991c 100644 --- a/dev/reference/quoting.html +++ b/dev/reference/quoting.html @@ -20,7 +20,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/reference/trim.html b/dev/reference/trim.html index 6c75e82..7a74641 100644 --- a/dev/reference/trim.html +++ b/dev/reference/trim.html @@ -32,7 +32,7 @@ glue - 1.6.2.9000 + 1.7.0.9000 diff --git a/dev/search.json b/dev/search.json index c19b5fe..fbce0f7 100644 --- a/dev/search.json +++ b/dev/search.json @@ -1 +1 @@ -[{"path":[]},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to glue","title":"Contributing to glue","text":"outlines propose change glue. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to glue","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to glue","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed).","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to glue","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"batpigandme/glue\", fork = TRUE). Install development dependences devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to glue","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to glue","text":"Please note glue project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://glue.tidyverse.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 glue authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"current-state","dir":"","previous_headings":"","what":"Current state","title":"NA","text":"Glue currently stable, used installed quite extensively relatively issues reported. issues reported tend center around glue_sql().","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"known-outstanding-issues","dir":"","previous_headings":"","what":"Known outstanding issues","title":"NA","text":"think need way optionally disable interpretation quotes, fix https://github.com/r-lib/cli/issues/370, long standing https://github.com/tidyverse/glue/issues/158 Possibly loading closing blank line behaviors tweaked, issues brought https://github.com/tidyverse/glue/issues/234 natural. may difficult maintaining backwards compatibility.","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"future-directions","dir":"","previous_headings":"","what":"Future directions","title":"NA","text":"include built-support custom numeric formats, suggested https://github.com/tidyverse/glue/issues/87 https://github.com/tidyverse/glue/issues/86? now avoided , common pain point glue Potentially revisit use custom glue class, gather also causes people grief practice?","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with glue","title":"Getting help with glue","text":"Thanks using glue! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with glue","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty insane ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with glue","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with glue","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"glue-engine","dir":"Articles","previous_headings":"","what":"glue engine","title":"glue custom knitr language engines","text":"first engine glue engine, evaluates chunk contents glue template. Maybe useful use glue engine set knitr option results = 'asis' output markdown HTML directly document.","code":"1 + 1 = {1 + 1} ## 1 + 1 = 2 ```{glue, results = 'asis', echo = FALSE} #### mtcars has **{nrow(mtcars)} rows** and _{ncol(mtcars)} columns_. ```"},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"mtcars-has-32-rows-and-11-columns-","dir":"Articles","previous_headings":"glue engine","what":"mtcars has 32 rows and 11 columns.","title":"glue custom knitr language engines","text":"want pass additional arguments glue call, simply include chunk options. median waiting time eruptions 76.","code":"```{glue, .open = \"<<\", .close = \">>\", results = 'asis', echo = FALSE} The **median waiting time** between eruptions is <>. ```"},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"glue_sql-engine","dir":"Articles","previous_headings":"","what":"glue_sql engine","title":"glue custom knitr language engines","text":"second engine glue_sql, use glue::glue_sql() generate SQL query run query using sql engine. First create new connection -memory SQLite database, write new table . Next define variables can use glue interpolate. can use glue_sql construct run query using variables database. Note need provide connection object connection chunk option. example two type quotes. first bare backtick, passed directly SQL engine unchanged. second backticks inside braces, specially interpreted proper quoting given SQL engine glue. example use sqlite engine, uses backticks quoting, use backticks inside brace syntax postgreSQL, glue_sql() automatically use double quotes quoting instead. Displaying records 1 - 10","code":"con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") mtcars$model <- rownames(mtcars) DBI::dbWriteTable(con, \"mtcars\", mtcars) var <- \"mpg\" tbl <- \"mtcars\" num <- 150 ```{glue_sql, connection = con} SELECT `model`, `hp`, {`var`} FROM {`tbl`} WHERE {`tbl`}.`hp` > {num} ``` SELECT `model`, `hp`, `mpg` FROM `mtcars` WHERE `mtcars`.`hp` > 150"},{"path":"https://glue.tidyverse.org/dev/articles/speed.html","id":"simple-concatenation","dir":"Articles","previous_headings":"","what":"Simple concatenation","title":"Speed of glue","text":"glue() slower paste0 sprintf(), twice fast gstring(), rprintf(). Although paste0() sprintf() don’t string interpolation likely always significantly faster glue, glue never meant direct replacement . rprintf::rprintf() variable interpolation, arbitrary expressions, one explicit goals writing glue. glue ~2x fast function (gstring()), roughly equivalent functionality. also still quite fast, 8000 evaluations per second machine.","code":"bar <- \"baz\" simple <- bench::mark( glue = as.character(glue::glue(\"foo{bar}\")), gstring = R.utils::gstring(\"foo${bar}\"), paste0 = paste0(\"foo\", bar), sprintf = sprintf(\"foo%s\", bar), rprintf = rprintf::rprintf(\"foo$bar\", bar = bar) ) simple %>% select(expression:total_time) %>% arrange(median) #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> #> 1 sprintf 711.07ns 811.07ns 1067910. 0B 107. #> 2 paste0 1.44µs 1.57µs 560352. 0B 0 #> 3 glue 98.51µs 106.49µs 8494. 139.66KB 30.0 #> 4 gstring 227.21µs 260.5µs 3293. 2.45MB 15.0 #> 5 rprintf 277.12µs 310.56µs 2776. 78.14KB 8.24 # plotting function defined in a hidden chunk plot_comparison(simple)"},{"path":"https://glue.tidyverse.org/dev/articles/speed.html","id":"vectorized-performance","dir":"Articles","previous_headings":"","what":"Vectorized performance","title":"Speed of glue","text":"Taking advantage glue’s vectorization best way improve performance. vectorized form previous benchmark, glue’s performance much closer paste0() sprintf().","code":"bar <- rep(\"bar\", 1e5) vectorized <- bench::mark( glue = as.character(glue::glue(\"foo{bar}\")), gstring = R.utils::gstring(\"foo${bar}\"), paste0 = paste0(\"foo\", bar), sprintf = sprintf(\"foo%s\", bar), rprintf = rprintf::rprintf(\"foo$bar\", bar = bar) ) vectorized %>% select(expression:total_time) %>% arrange(median) #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> #> 1 paste0 8.34ms 8.37ms 119. 781.3KB 4.17 #> 2 sprintf 9.6ms 9.87ms 101. 781.3KB 4.14 #> 3 gstring 11.2ms 11.34ms 85.4 1.53MB 4.17 #> 4 glue 12.81ms 13.32ms 71.1 2.29MB 6.46 #> 5 rprintf 27.55ms 27.78ms 36.0 3.05MB 4.50 # plotting function defined in a hidden chunk plot_comparison(vectorized)"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"collapse-transformer","dir":"Articles","previous_headings":"","what":"collapse transformer","title":"Transformers","text":"transformer automatically collapses glue block ending *.","code":"collapse_transformer <- function(regex = \"[*]$\", ...) { function(text, envir) { collapse <- grepl(regex, text) if (collapse) { text <- sub(regex, \"\", text) } res <- identity_transformer(text, envir) if (collapse) { glue_collapse(res, ...) } else { res } } } glue(\"{1:5*}\\n{letters[1:5]*}\", .transformer = collapse_transformer(sep = \", \")) #> 1, 2, 3, 4, 5 #> a, b, c, d, e glue(\"{1:5*}\\n{letters[1:5]*}\", .transformer = collapse_transformer(sep = \", \", last = \" and \")) #> 1, 2, 3, 4 and 5 #> a, b, c, d and e x <- c(\"one\", \"two\") glue(\"{x}: {1:5*}\", .transformer = collapse_transformer(sep = \", \")) #> one: 1, 2, 3, 4, 5 #> two: 1, 2, 3, 4, 5"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"shell-quoting-transformer","dir":"Articles","previous_headings":"","what":"Shell quoting transformer","title":"Transformers","text":"transformer automatically quotes variables use shell commands, e.g. via system() system2().","code":"shell_transformer <- function(type = c(\"sh\", \"csh\", \"cmd\", \"cmd2\")) { type <- match.arg(type) function(text, envir) { res <- identity_transformer(text, envir) shQuote(res) } } glue_sh <- function(..., .envir = parent.frame(), .type = c(\"sh\", \"csh\", \"cmd\", \"cmd2\")) { .type <- match.arg(.type) glue(..., .envir = .envir, .transformer = shell_transformer(.type)) } filename <- \"test\" writeLines(con = filename, \"hello!\") command <- glue_sh(\"cat {filename}\") command #> cat 'test' system(command)"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"emoji-transformer","dir":"Articles","previous_headings":"","what":"emoji transformer","title":"Transformers","text":"transformer converts text equivalent emoji.","code":"emoji_transformer <- function(text, envir) { if (grepl(\"[*]$\", text)) { text <- sub(\"[*]$\", \"\", text) glue_collapse(ji_find(text)$emoji) } else { ji(text) } } glue_ji <- function(..., .envir = parent.frame()) { glue(..., .open = \":\", .close = \":\", .envir = .envir, .transformer = emoji_transformer) } glue_ji(\"one :heart:\") glue_ji(\"many :heart*:\")"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"sprintf-transformer","dir":"Articles","previous_headings":"","what":"sprintf transformer","title":"Transformers","text":"transformer allows succinct sprintf format strings.","code":"sprintf_transformer <- function(text, envir) { m <- regexpr(\":.+$\", text) if (m != -1) { format <- substring(regmatches(text, m), 2) regmatches(text, m) <- \"\" res <- identity_transformer(text, envir) do.call(sprintf, list(glue(\"%{format}\"), res)) } else { identity_transformer(text, envir) } } glue_fmt <- function(..., .envir = parent.frame()) { glue(..., .transformer = sprintf_transformer, .envir = .envir) } glue_fmt(\"π = {pi:.3f}\") #> π = 3.142"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"signif-transformer","dir":"Articles","previous_headings":"","what":"signif transformer","title":"Transformers","text":"transformer generator represents numbers given number significant digits. useful want represent numbers using significant digits","code":"signif_transformer <- function(digits = 3) { force(digits) function(text, envir) { x <- identity_transformer(text, envir) if (is.numeric(x)) { signif(x, digits = digits) } else { x } } } glue_signif <- function(..., .envir = parent.frame()) { glue(..., .transformer = signif_transformer(3), .envir = .envir) } glue_signif(\"π = {pi}; 10π = {10*pi}; 100π = {100*pi}\") #> π = 3.14; 10π = 31.4; 100π = 314"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"safely-transformer","dir":"Articles","previous_headings":"","what":"safely transformer","title":"Transformers","text":"transformer acts like purrr::safely(), returns value instead error.","code":"safely_transformer <- function(otherwise = NA) { function(text, envir) { tryCatch( identity_transformer(text, envir), error = function(e) if (is.language(otherwise)) eval(otherwise) else otherwise) } } glue_safely <- function(..., .otherwise = NA, .envir = parent.frame()) { glue(..., .transformer = safely_transformer(.otherwise), .envir = .envir) } # Default returns missing if there is an error glue_safely(\"foo: {xyz}\") #> foo: NA # Or an empty string glue_safely(\"foo: {xyz}\", .otherwise = \"Error\") #> foo: Error # Or output the error message in red library(crayon) glue_safely(\"foo: {xyz}\", .otherwise = quote(glue(\"{red}Error: {conditionMessage(e)}{reset}\"))) #> foo: Error: Failed to evaluate glue component {xyz} #> Caused by error: #> ! object 'xyz' not found"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"variables-and-values-transformer","dir":"Articles","previous_headings":"","what":"“Variables and Values” transformer","title":"Transformers","text":"transformer expands input form {var_name=} var_name = var_value, .e. shorthand exposing variable names values. inspired f-strings feature coming Python 3.8. ’s actually general: can use expression input {expr=}.","code":"vv_transformer <- function(text, envir) { regex <- \"=$\" if (!grepl(regex, text)) { return(identity_transformer(text, envir)) } text <- sub(regex, \"\", text) res <- identity_transformer(text, envir) n <- length(res) res <- glue_collapse(res, sep = \", \") if (n > 1) { res <- c(\"[\", res, \"]\") } glue_collapse(c(text, \" = \", res)) } set.seed(1234) description <- \"some random\" numbers <- sample(100, 4) average <- mean(numbers) sum <- sum(numbers) glue(\"For {description} {numbers=}, {average=}, {sum=}.\", .transformer = vv_transformer) #> For some random numbers = [28, 80, 22, 9], average = 34.75, sum = 139. a <- 3 b <- 5.6 glue(\"{a=}\\n{b=}\\n{a * 9 + b * 2=}\", .transformer = vv_transformer) #> a = 3 #> b = 5.6 #> a * 9 + b * 2 = 38.2"},{"path":"https://glue.tidyverse.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jim Hester. Author. Jennifer Bryan. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://glue.tidyverse.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hester J, Bryan J (2023). glue: Interpreted String Literals. R package version 1.6.2.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/.","code":"@Manual{, title = {glue: Interpreted String Literals}, author = {Jim Hester and Jennifer Bryan}, year = {2023}, note = {R package version 1.6.2.9000, https://github.com/tidyverse/glue}, url = {https://glue.tidyverse.org/}, }"},{"path":[]},{"path":"https://glue.tidyverse.org/dev/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Interpreted String Literals","text":"Glue offers interpreted string literals small, fast, dependency-free. Glue embedding R expressions curly braces evaluated inserted argument string.","code":""},{"path":"https://glue.tidyverse.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Interpreted String Literals","text":"","code":"# Install development version from GitHub pak::pak(\"tidyverse/glue\")"},{"path":[]},{"path":"https://glue.tidyverse.org/dev/index.html","id":"variables-can-be-passed-directly-into-strings","dir":"","previous_headings":"Usage","what":"Variables can be passed directly into strings.","title":"Interpreted String Literals","text":"Note glue::glue() also made available via stringr::str_glue(). ’ve already attached stringr (perhaps whole tidyverse), can access glue() like :","code":"library(glue) name <- \"Fred\" glue('My name is {name}.') #> My name is Fred. library(stringr) # or library(tidyverse) stringr_fcn <- \"`stringr::str_glue()`\" glue_fcn <- \"`glue::glue()`\" str_glue('{stringr_fcn} is essentially an alias for {glue_fcn}.') #> `stringr::str_glue()` is essentially an alias for `glue::glue()`."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"long-strings-are-broken-by-line-and-concatenated-together","dir":"","previous_headings":"Usage","what":"Long strings are broken by line and concatenated together.","title":"Interpreted String Literals","text":"","code":"library(glue) name <- \"Fred\" age <- 50 anniversary <- as.Date(\"1991-10-12\") glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.') #> My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"named-arguments-are-used-to-assign-temporary-variables","dir":"","previous_headings":"Usage","what":"Named arguments are used to assign temporary variables.","title":"Interpreted String Literals","text":"","code":"glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.', name = \"Joe\", age = 40, anniversary = as.Date(\"2001-10-12\")) #> My name is Joe, my age next year is 41, my anniversary is Friday, October 12, 2001."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue_data-is-useful-with-magrittr-pipes","dir":"","previous_headings":"Usage","what":"glue_data() is useful with magrittr pipes.","title":"Interpreted String Literals","text":"","code":"`%>%` <- magrittr::`%>%` head(mtcars) %>% glue_data(\"{rownames(.)} has {hp} hp\") #> Mazda RX4 has 110 hp #> Mazda RX4 Wag has 110 hp #> Datsun 710 has 93 hp #> Hornet 4 Drive has 110 hp #> Hornet Sportabout has 175 hp #> Valiant has 105 hp"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue-is-useful-within-dplyr-pipelines","dir":"","previous_headings":"Usage","what":"glue() is useful within dplyr pipelines","title":"Interpreted String Literals","text":"","code":"library(dplyr) head(iris) %>% mutate(description = glue(\"This {Species} has a petal length of {Petal.Length}\")) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa #> description #> 1 This setosa has a petal length of 1.4 #> 2 This setosa has a petal length of 1.4 #> 3 This setosa has a petal length of 1.3 #> 4 This setosa has a petal length of 1.5 #> 5 This setosa has a petal length of 1.4 #> 6 This setosa has a petal length of 1.7"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"leading-whitespace-and-blank-lines-from-the-first-and-last-lines-are-automatically-trimmed","dir":"","previous_headings":"Usage","what":"Leading whitespace and blank lines from the first and last lines are automatically trimmed.","title":"Interpreted String Literals","text":"lets indent strings naturally code.","code":"glue(\" A formatted string Can have multiple lines with additional indention preserved \") #> A formatted string #> Can have multiple lines #> with additional indention preserved"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"an-additional-newline-can-be-used-if-you-want-a-leading-or-trailing-newline","dir":"","previous_headings":"Usage","what":"An additional newline can be used if you want a leading or trailing newline.","title":"Interpreted String Literals","text":"","code":"glue(\" leading or trailing newlines can be added explicitly \") #> #> leading or trailing newlines can be added explicitly"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"id_-at-the-end-of-a-line-continues-it-without-a-new-line","dir":"","previous_headings":"Usage","what":"\\\\ at the end of a line continues it without a new line.","title":"Interpreted String Literals","text":"","code":"glue(\" A formatted string \\\\ can also be on a \\\\ single line \") #> A formatted string can also be on a single line"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"a-literal-brace-is-inserted-by-using-doubled-braces","dir":"","previous_headings":"Usage","what":"A literal brace is inserted by using doubled braces.","title":"Interpreted String Literals","text":"","code":"name <- \"Fred\" glue(\"My name is {name}, not {{name}}.\") #> My name is Fred, not {name}."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"alternative-delimiters-can-be-specified-with-open-and-close","dir":"","previous_headings":"Usage","what":"Alternative delimiters can be specified with .open and .close.","title":"Interpreted String Literals","text":"","code":"one <- \"1\" glue(\"The value of $e^{2\\\\pi i}$ is $<>$.\", .open = \"<<\", .close = \">>\") #> The value of $e^{2\\pi i}$ is $1$."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"all-valid-r-code-works-in-expressions-including-braces-and-escaping","dir":"","previous_headings":"Usage","what":"All valid R code works in expressions, including braces and escaping.","title":"Interpreted String Literals","text":"Backslashes need doubled just like R strings.","code":"`foo}\\`` <- \"foo\" glue(\"{ { '}\\\\'' # { and } in comments, single quotes \\\"}\\\\\\\"\\\" # or double quotes are ignored `foo}\\\\`` # as are { in backticks } }\") #> foo"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue_sql-makes-constructing-sql-statements-safe-and-easy","dir":"","previous_headings":"Usage","what":"glue_sql() makes constructing SQL statements safe and easy","title":"Interpreted String Literals","text":"Use backticks quote identifiers, normal strings numbers quoted appropriately backend.","code":"library(glue) con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") colnames(iris) <- gsub(\"[.]\", \"_\", tolower(colnames(iris))) DBI::dbWriteTable(con, \"iris\", iris) var <- \"sepal_width\" tbl <- \"iris\" num <- 2 val <- \"setosa\" glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {num} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > 2 #> AND `iris`.species = 'setosa' # `glue_sql()` can be used in conjunction with parameterized queries using # `DBI::dbBind()` to provide protection for SQL Injection attacks sql <- glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > ? \", .con = con) query <- DBI::dbSendQuery(con, sql) DBI::dbBind(query, list(num)) DBI::dbFetch(query, n = 4) #> sepal_width #> 1 3.5 #> 2 3.0 #> 3 3.2 #> 4 3.1 DBI::dbClearResult(query) # `glue_sql()` can be used to build up more complex queries with # interchangeable sub queries. It returns `DBI::SQL()` objects which are # properly protected from quoting. sub_query <- glue_sql(\" SELECT * FROM {`tbl`} \", .con = con) glue_sql(\" SELECT s.{`var`} FROM ({sub_query}) AS s \", .con = con) #> SELECT s.`sepal_width` #> FROM (SELECT * #> FROM `iris`) AS s # If you want to input multiple values for use in SQL IN statements put `*` # at the end of the value and the values will be collapsed and quoted appropriately. glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1) glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1:5, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1, 2, 3, 4, 5) glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = \"setosa\", .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa') glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = c(\"setosa\", \"versicolor\"), .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa', 'versicolor')"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"other-implementations","dir":"","previous_headings":"","what":"Other implementations","title":"Interpreted String Literals","text":"implementations string interpolation R (although using identical syntax). stringr::str_interp R.utils::gstring rprintf String templating closely related string interpolation, although exactly concept. packages implementing string templating R include. whisker brew jinjar","code":""},{"path":"https://glue.tidyverse.org/dev/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Interpreted String Literals","text":"Please note glue project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":null,"dir":"Reference","previous_headings":"","what":"Coerce object to glue — as_glue","title":"Coerce object to glue — as_glue","text":"glue object character vector S3 class \"glue\". \"glue\" class implements print method shows literal contents (rather string implementation) + method, can concatenate addition operator.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coerce object to glue — as_glue","text":"","code":"as_glue(x, ...)"},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coerce object to glue — as_glue","text":"x object coerced. ... arguments passed methods.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coerce object to glue — as_glue","text":"character vector S3 class \"glue\".","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coerce object to glue — as_glue","text":"","code":"x <- as_glue(c(\"abc\", \"\\\"\\\\\\\\\", \"\\n\")) x #> abc #> \"\\\\ #> #> x <- 1 y <- 3 glue(\"x + y\") + \" = {x + y}\" #> x + y = {x + y}"},{"path":"https://glue.tidyverse.org/dev/reference/glue-deprecated.html","id":null,"dir":"Reference","previous_headings":"","what":"Deprecated Functions — glue-deprecated","title":"Deprecated Functions — glue-deprecated","text":"functions Deprecated release glue, removed future version.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":null,"dir":"Reference","previous_headings":"","what":"Format and interpolate a string — glue","title":"Format and interpolate a string — glue","text":"Expressions enclosed braces evaluated R code. Long strings broken line concatenated together. Leading whitespace blank lines first last lines automatically trimmed.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format and interpolate a string — glue","text":"","code":"glue_data( .x, ..., .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = \"NA\", .null = character(), .comment = \"#\", .literal = FALSE, .transformer = identity_transformer, .trim = TRUE ) glue( ..., .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = \"NA\", .null = character(), .comment = \"#\", .literal = FALSE, .transformer = identity_transformer, .trim = TRUE )"},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format and interpolate a string — glue","text":".x [listish] environment, list, data frame used lookup values. ... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .sep [character(1): ‘\"\"’] Separator used separate elements. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .open [character(1): ‘\\{’] opening delimiter. Doubling full delimiter escapes . .close [character(1): ‘\\}’] closing delimiter. Doubling full delimiter escapes . .na [character(1): ‘NA’] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .null [character(1): ‘character()’] Value replace NULL values . character() whole output character(). NULL NULL values dropped (paste0()). Otherwise value replaced value .null. .comment [character(1): ‘#’] Value use comment character. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .transformer [function] function taking two arguments, text envir, text unparsed string inside glue block envir execution environment. .transformer lets modify glue block , , evaluation, allowing create custom glue()-like functions. See vignette(\"transformers\") examples. .trim [logical(1): ‘TRUE’] Whether trim input template trim() .","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format and interpolate a string — glue","text":"glue object, created as_glue().","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format and interpolate a string — glue","text":"","code":"name <- \"Fred\" age <- 50 anniversary <- as.Date(\"1991-10-12\") glue('My name is {name},', 'my age next year is {age + 1},', 'my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.') #> My name is Fred,my age next year is 51,my anniversary is Saturday, October 12, 1991. # single braces can be inserted by doubling them glue(\"My name is {name}, not {{name}}.\") #> My name is Fred, not {name}. # Named arguments can be used to assign temporary variables. glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.', name = \"Joe\", age = 40, anniversary = as.Date(\"2001-10-12\")) #> My name is Joe, my age next year is 41, my anniversary is Friday, October 12, 2001. # `glue()` can also be used in user defined functions intro <- function(name, profession, country){ glue(\"My name is {name}, a {profession}, from {country}\") } intro(\"Shelmith\", \"Senior Data Analyst\", \"Kenya\") #> My name is Shelmith, a Senior Data Analyst, from Kenya intro(\"Cate\", \"Data Scientist\", \"Kenya\") #> My name is Cate, a Data Scientist, from Kenya # `glue_data()` is useful in magrittr pipes if (require(magrittr)) { mtcars %>% glue_data(\"{rownames(.)} has {hp} hp\") # Or within dplyr pipelines if (require(dplyr)) { head(iris) %>% mutate(description = glue(\"This {Species} has a petal length of {Petal.Length}\")) }} #> Loading required package: magrittr #> Loading required package: 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 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa #> description #> 1 This setosa has a petal length of 1.4 #> 2 This setosa has a petal length of 1.4 #> 3 This setosa has a petal length of 1.3 #> 4 This setosa has a petal length of 1.5 #> 5 This setosa has a petal length of 1.4 #> 6 This setosa has a petal length of 1.7 # Alternative delimiters can also be used if needed one <- \"1\" glue(\"The value of $e^{2\\\\pi i}$ is $<>$.\", .open = \"<<\", .close = \">>\") #> The value of $e^{2\\pi i}$ is $1$."},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":null,"dir":"Reference","previous_headings":"","what":"Construct strings with color — glue_col","title":"Construct strings with color — glue_col","text":"crayon package defines number functions used color terminal output. glue_col() glue_data_col() functions provide additional syntax make using functions glue strings easier. Using following syntax apply function crayon::blue() text 'foo bar'. want expression evaluated, simply place normal brace expression (can nested). text want color contains, e.g., unpaired quote comment character, specify .literal = TRUE.","code":"{blue foo bar} {blue 1 + 1 = {1 + 1}}"},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Construct strings with color — glue_col","text":"","code":"glue_col(..., .envir = parent.frame(), .na = \"NA\", .literal = FALSE) glue_data_col(.x, ..., .envir = parent.frame(), .na = \"NA\", .literal = FALSE)"},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Construct strings with color — glue_col","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .na [character(1): ‘NA’] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Construct strings with color — glue_col","text":"glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Construct strings with color — glue_col","text":"","code":"library(crayon) glue_col(\"{blue foo bar}\") #> foo bar glue_col(\"{blue 1 + 1 = {1 + 1}}\") #> 1 + 1 = 2 glue_col(\"{blue 2 + 2 = {green {2 + 2}}}\") #> 2 + 2 = 4 white_on_black <- bgBlack $ white glue_col(\"{white_on_black Roses are {red {colors()[[552]]}}, Violets are {blue {colors()[[26]]}}, `glue_col()` can show \\\\ {red c}{yellow o}{green l}{cyan o}{blue r}{magenta s} and {bold bold} and {underline underline} too! }\") #> Roses are red, #> Violets are blue, #> `glue_col()` can show colors #> and bold and underline too! # this would error due to an unterminated quote, if we did not specify # `.literal = TRUE` glue_col(\"{yellow It's} happening!\", .literal = TRUE) #> It's happening! # `.literal = TRUE` also prevents an error here due to the `#` comment glue_col( \"A URL: {magenta https://github.com/tidyverse/glue#readme}\", .literal = TRUE ) #> A URL: https://github.com/tidyverse/glue#readme # `.literal = TRUE` does NOT prevent evaluation x <- \"world\" y <- \"day\" glue_col(\"hello {x}! {green it's a new {y}!}\", .literal = TRUE) #> hello world! it's a new day!"},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse a character vector — glue_collapse","title":"Collapse a character vector — glue_collapse","text":"glue_collapse() collapses character vector length length 1 vector. glue_sql_collapse() returns [DBI::SQL()] object rather glue object.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse a character vector — glue_collapse","text":"","code":"glue_collapse(x, sep = \"\", width = Inf, last = \"\") glue_sql_collapse(x, sep = \"\", width = Inf, last = \"\")"},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse a character vector — glue_collapse","text":"x character vector collapse. sep character string separate terms. NA_character_. width maximum string width truncating .... last String used separate last two items x least 2 items.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse a character vector — glue_collapse","text":"Always returns length-1 glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse a character vector — glue_collapse","text":"","code":"glue_collapse(glue(\"{1:10}\")) #> 12345678910 # Wide values can be truncated glue_collapse(glue(\"{1:10}\"), width = 5) #> 12... glue_collapse(1:4, \", \", last = \" and \") #> 1, 2, 3 and 4"},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":null,"dir":"Reference","previous_headings":"","what":"Safely interpolate strings — glue_safe","title":"Safely interpolate strings — glue_safe","text":"glue_safe() glue_data_safe() differ glue() glue_data() safe versions look symbols environment using get(). execute R code. makes suitable use untrusted input, inputs Shiny application, using normal functions allow attacker execute arbitrary code.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Safely interpolate strings — glue_safe","text":"","code":"glue_safe(..., .envir = parent.frame()) glue_data_safe(.x, ..., .envir = parent.frame())"},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Safely interpolate strings — glue_safe","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Safely interpolate strings — glue_safe","text":"glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Safely interpolate strings — glue_safe","text":"","code":"\"1 + 1\" <- 5 # glue actually executes the code glue(\"{1 + 1}\") #> 2 # glue_safe just looks up the value glue_safe(\"{1 + 1}\") #> 5 rm(\"1 + 1\")"},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":null,"dir":"Reference","previous_headings":"","what":"Interpolate strings with SQL escaping — glue_sql","title":"Interpolate strings with SQL escaping — glue_sql","text":"SQL databases often custom quotation syntax identifiers strings make writing SQL queries error prone cumbersome . glue_sql() glue_data_sql() analogs glue() glue_data() handle SQL quoting. glue_sql_collapse() can used collapse DBI::SQL() objects. automatically quote character results, quote identifiers glue expression surrounded backticks '`' quote non-characters numbers. numeric data stored character column (quoted) pass data glue_sql() character. Returning result DBI::SQL() suppress quoting desired given value. Note parameterized queries generally safest efficient way pass user defined values query, however every database driver supports . place * end glue expression values collapsed commas. useful SQL Operator instance.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Interpolate strings with SQL escaping — glue_sql","text":"","code":"glue_sql( ..., .con, .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = DBI::SQL(\"NULL\"), .null = character(), .comment = \"#\", .literal = FALSE, .trim = TRUE ) glue_data_sql( .x, ..., .con, .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = DBI::SQL(\"NULL\"), .null = character(), .comment = \"#\", .literal = FALSE, .trim = TRUE )"},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Interpolate strings with SQL escaping — glue_sql","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .con [DBIConnection]: DBI connection object obtained DBI::dbConnect(). .sep [character(1): ‘\"\"’] Separator used separate elements. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .open [character(1): ‘\\{’] opening delimiter. Doubling full delimiter escapes . .close [character(1): ‘\\}’] closing delimiter. Doubling full delimiter escapes . .na [character(1): DBI::SQL(\"NULL\")] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .null [character(1): ‘character()’] Value replace NULL values . character() whole output character(). NULL NULL values dropped (paste0()). Otherwise value replaced value .null. .comment [character(1): ‘#’] Value use comment character. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .trim [logical(1): ‘TRUE’] Whether trim input template trim() . .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Interpolate strings with SQL escaping — glue_sql","text":"DBI::SQL() object given query.","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Interpolate strings with SQL escaping — glue_sql","text":"","code":"con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") iris2 <- iris colnames(iris2) <- gsub(\"[.]\", \"_\", tolower(colnames(iris))) DBI::dbWriteTable(con, \"iris\", iris2) var <- \"sepal_width\" tbl <- \"iris\" num <- 2 val <- \"setosa\" glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {num} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > 2 #> AND `iris`.species = 'setosa' # If sepal_length is store on the database as a character explicitly convert # the data to character to quote appropriately. glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {as.character(num)} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > '2' #> AND `iris`.species = 'setosa' # `glue_sql()` can be used in conjuction with parameterized queries using # `DBI::dbBind()` to provide protection for SQL Injection attacks sql <- glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > ? \", .con = con) query <- DBI::dbSendQuery(con, sql) DBI::dbBind(query, list(num)) DBI::dbFetch(query, n = 4) #> sepal_width #> 1 3.5 #> 2 3.0 #> 3 3.2 #> 4 3.1 DBI::dbClearResult(query) # `glue_sql()` can be used to build up more complex queries with # interchangeable sub queries. It returns `DBI::SQL()` objects which are # properly protected from quoting. sub_query <- glue_sql(\" SELECT * FROM {`tbl`} \", .con = con) glue_sql(\" SELECT s.{`var`} FROM ({sub_query}) AS s \", .con = con) #> SELECT s.`sepal_width` #> FROM (SELECT * #> FROM `iris`) AS s # If you want to input multiple values for use in SQL IN statements put `*` # at the end of the value and the values will be collapsed and quoted appropriately. glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1) glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1:5, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1, 2, 3, 4, 5) glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = \"setosa\", .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa') glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = c(\"setosa\", \"versicolor\"), .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa', 'versicolor') # If you need to reference variables from multiple tables use `DBI::Id()`. # Here we create a new table of nicknames, join the two tables together and # select columns from both tables. Using `DBI::Id()` and the special # `glue_sql()` syntax ensures all the table and column identifiers are quoted # appropriately. iris_db <- \"iris\" nicknames_db <- \"nicknames\" nicknames <- data.frame( species = c(\"setosa\", \"versicolor\", \"virginica\"), nickname = c(\"Beachhead Iris\", \"Harlequin Blueflag\", \"Virginia Iris\"), stringsAsFactors = FALSE ) DBI::dbWriteTable(con, nicknames_db, nicknames) cols <- list( DBI::Id(iris_db, \"sepal_length\"), DBI::Id(iris_db, \"sepal_width\"), DBI::Id(nicknames_db, \"nickname\") ) iris_species <- DBI::Id(iris_db, \"species\") nicknames_species <- DBI::Id(nicknames_db, \"species\") query <- glue_sql(\" SELECT {`cols`*} FROM {`iris_db`} JOIN {`nicknames_db`} ON {`iris_species`}={`nicknames_species`}\", .con = con ) query #> SELECT `iris`.`sepal_length`, `iris`.`sepal_width`, `nicknames`.`nickname` #> FROM `iris` #> JOIN `nicknames` #> ON `iris`.`species`=`nicknames`.`species` DBI::dbGetQuery(con, query, n = 5) #> sepal_length sepal_width nickname #> 1 5.1 3.5 Beachhead Iris #> 2 4.9 3.0 Beachhead Iris #> 3 4.7 3.2 Beachhead Iris #> 4 4.6 3.1 Beachhead Iris #> 5 5.0 3.6 Beachhead Iris DBI::dbDisconnect(con)"},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse and Evaluate R code — identity_transformer","title":"Parse and Evaluate R code — identity_transformer","text":"simple wrapper around eval(parse()), used default transformer.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse and Evaluate R code — identity_transformer","text":"","code":"identity_transformer(text, envir = parent.frame())"},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse and Evaluate R code — identity_transformer","text":"text Text (typically) R code parse evaluate. envir environment evaluate code ","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":null,"dir":"Reference","previous_headings":"","what":"Quoting operators — quoting","title":"Quoting operators — quoting","text":"functions make easy quote individual element useful conjunction glue_collapse(). thin wrappers around base::encodeString().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quoting operators — quoting","text":"","code":"single_quote(x) double_quote(x) backtick(x)"},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quoting operators — quoting","text":"x character quote.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quoting operators — quoting","text":"character vector length x, attributes (including names dimensions) class set. Marked UTF-8 encodings preserved.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quoting operators — quoting","text":"","code":"x <- 1:5 glue('Values of x: {glue_collapse(backtick(x), sep = \", \", last = \" and \")}') #> Values of x: `1`, `2`, `3`, `4` and `5`"},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":null,"dir":"Reference","previous_headings":"","what":"Trim a character vector — trim","title":"Trim a character vector — trim","text":"trims character vector according trimming rules used glue. follow similar rules Python Docstrings, following features. Leading trailing whitespace first last lines removed. uniform amount indentation stripped second line , equal minimum indentation non-blank lines first. Lines can continued across newlines using \\\\.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trim a character vector — trim","text":"","code":"trim(x)"},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trim a character vector — trim","text":"x character vector trim.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trim a character vector — trim","text":"character vector.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trim a character vector — trim","text":"","code":"glue(\" A formatted string Can have multiple lines with additional indention preserved \") #> A formatted string #> Can have multiple lines #> with additional indention preserved glue(\" \\ntrailing or leading newlines can be added explicitly\\n \") #> #> trailing or leading newlines can be added explicitly #> glue(\" A formatted string \\\\ can also be on a \\\\ single line \") #> A formatted string can also be on a single line"},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-development-version","dir":"Changelog","previous_headings":"","what":"glue (development version)","title":"glue (development version)","text":"rlang installed, glue generate informative errors interpolated expression either can’t parsed fails evaluate (#229). + now works situations, gives errors one side isn’t character vector. longer automatically applies glue interpolation non-glue input, one. ’ll need (#286). glue_collapse(character()) (hence glue_sql_collapse(character())) now return \"\", always return single string (#88). glue_sql() now collapses empty vector \"\" \"NULL\" (#272). glue_sql() now uses DBI::dbQuoteLiteral() object types. increase fidelity escaping different object types (#279). “Speed glue” vignette converted article, allows several package removed Suggests (re-located Config/Needs/website). code got light refresh, including switch microbenchmark bench modern use ggplot2. Add $(C_VISIBILITY) compiler flags hide internal symbols dll (#284 @lionel-).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-162","dir":"Changelog","previous_headings":"","what":"glue 1.6.2","title":"glue 1.6.2","text":"CRAN release: 2022-02-24 Modify test better forward compatibility R.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-161","dir":"Changelog","previous_headings":"","what":"glue 1.6.1","title":"glue 1.6.1","text":"CRAN release: 2022-01-22 glue now registers custom knitr engines way robust namespace-loading edge cases can arise package installation (#254).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-160","dir":"Changelog","previous_headings":"","what":"glue 1.6.0","title":"glue 1.6.0","text":"CRAN release: 2021-12-17 glue(), glue_data(), glue_col(), glue_data_col() gain new .literal argument, controls quotes comment character treated parsing expression string (#235). mostly useful using custom transformer. Trailing whitespace-lines don’t interfere indentation (#247).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-151","dir":"Changelog","previous_headings":"","what":"glue 1.5.1","title":"glue 1.5.1","text":"CRAN release: 2021-11-30 Jennifer Bryan now maintainer. existing custom language engines knitr, glue glue_sql, documented new vignette (#71). Detail added release: glue now sets registration engines .onLoad(). glue_col() gives special treatment styling functions crayon package, e.g. glue_col(\"{blue foo}\") “just works” now, even crayon attached (installed) (#241). Unterminated backticks trigger error unterminated single double quotes (#237). glue_sql() collapses zero-length DBI::SQL object DBI::SQL(\"NULL\") (#244 @shrektan).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-150","dir":"Changelog","previous_headings":"","what":"glue 1.5.0","title":"glue 1.5.0","text":"CRAN release: 2021-11-06","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"breaking-changes-1-5-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"glue 1.5.0","text":"Long deprecated function collapse() removed (#213)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"new-functions-and-arguments-1-5-0","dir":"Changelog","previous_headings":"","what":"New functions and arguments","title":"glue 1.5.0","text":"New glue_sql_collapse() function collapse inputs return DBI::SQL() object (#103). glue() gains new .comment argument, control comment character (#193). glue() gains new .null argument, control value replace NULL values (#217, @echasnovski).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-5-0","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.5.0","text":"sql_quote_transformer() now allows whitespace trailing * (#218). compare_proxy.glue() method defined glue objects can compared strings testthat 3e without errors (#212) print.glue() longer prints empty newline 0 length inputs (#214) Unterminated comments glue expression now throw error (#227, @gaborcsardi) Unterminated quotes glue expressions now throw error (#226, @gaborcsardi)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-142","dir":"Changelog","previous_headings":"","what":"glue 1.4.2","title":"glue 1.4.2","text":"CRAN release: 2020-08-27 glue_safe() gives slightly nicer error message required version R now 3.2 (#189) glue_sql() now collapses DBI::SQL() elements correctly (#192 @shrektan) internal compare() method gains ... argument, compatibility testthat 3.0.0","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-141","dir":"Changelog","previous_headings":"","what":"glue 1.4.1","title":"glue 1.4.1","text":"CRAN release: 2020-05-13 Internal changes compatibility vctrs 0.3.0 (#187). glue_sql() now replaces missing values correctly collapsing values (#185). glue_sql() now always preserves type column even presence missing values (#130)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-140","dir":"Changelog","previous_headings":"","what":"glue 1.4.0","title":"glue 1.4.0","text":"CRAN release: 2020-04-03 .envir = NULL now supported equivalent passing .envir = emptyenv() (#140) New glue_safe() glue_data_safe() functions, safer versions glue() execute code, look values (using get()). alternatives useful things like shiny applications control input glue expressions. (#140) Fixed memory access issue memory leaks found valgrind.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-132","dir":"Changelog","previous_headings":"","what":"glue 1.3.2","title":"glue 1.3.2","text":"CRAN release: 2020-03-12 glue now implements vctrs methods. ensures vectors glue strings compatible tidyverse packages like tidyr (r-lib/tidyselect#170, tidyverse/tidyr#773, @lionel-). Fix LTO type mismatch warning (#146) glue_sql() now quotes lists values appropriate type, rather coercing values characters (#153) glue_data() now implicitly coerces .x list. glue() gains .trim argument, like glue_data(). single_quote() double_quote() backtick() return NA NA inputs (#135). Improve trim()’s handling lines containing indentation (#162, #163, @alandipert)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-131","dir":"Changelog","previous_headings":"","what":"glue 1.3.1","title":"glue 1.3.1","text":"CRAN release: 2019-03-12","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"features-1-3-1","dir":"Changelog","previous_headings":"","what":"Features","title":"glue 1.3.1","text":"glue() now + method combine strings. glue_sql() now collapses zero-length vector DBI::SQL(\"NULL\") (#134 @shrektan).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-3-1","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.3.1","text":"glue_sql() now supports unquoting lists Id objects. glue_sql() now quotes characters NAs appropriately (#115). glue_sql() now quotes Dates appropriately (#98). potential protection error reported rchk fixed.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-130","dir":"Changelog","previous_headings":"","what":"glue 1.3.0","title":"glue 1.3.0","text":"CRAN release: 2018-07-17","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"breaking-changes-1-3-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"glue 1.3.0","text":"evaluate() function removed. Changes elsewhere glue made implementation trivial removed sake clarity. Previous uses can replaced eval(parse(text = text), envir). collapse() renamed glue_collapse() avoid namespace collisions dplyr::collapse().","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"features-1-3-0","dir":"Changelog","previous_headings":"","what":"Features","title":"glue 1.3.0","text":"compare.glue() added, make easier use glue objects testthat::expect_equal() statements. glue_col() glue_data_col() functions added display strings color.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-3-0","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.3.0","text":"Glue now throws informative error message interpolate function string (#114, @haleyjeppson & @ijlyttle). Glue now evaluates unnamed arguments lazily delayedAssign(), performance cost argument used. (#83, @egnha). Fixed bug names assigned expression interpolation variable conflict name variable (#89, @egnha). drop glue class subsetting (#66). Fix glue() collapse() always return UTF-8 encoded strings (#81, @dpprdan)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-120","dir":"Changelog","previous_headings":"","what":"glue 1.2.0","title":"glue 1.2.0","text":"CRAN release: 2017-10-29 implementation tweaked slightly faster cases. glue() now .transformer argument, allows use custom logic evaluate code within glue blocks. See vignette(\"transformers\") details example transformer functions. glue() now returns NA results NA .na NULL. Otherwise NA values replaced value .na. trim() use trimming logic glue now exported. glue_sql() glue_data_sql() functions added make constructing SQL statements glue safer easier. glue() now easier use used within helper functions lapply. Fix last expression glue() NULL.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-111","dir":"Changelog","previous_headings":"","what":"glue 1.1.1","title":"glue 1.1.1","text":"CRAN release: 2017-06-21 Another fix PROTECT / REPROTECT found rchk static analyzer.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-110","dir":"Changelog","previous_headings":"","what":"glue 1.1.0","title":"glue 1.1.0","text":"CRAN release: 2017-06-13 Fix PROTECT errors resizing output strings. glue() always returns ‘UTF-8’ strings, converting inputs encodings needed. () to_data() removed. glue() glue_data() can now take alternative delimiters { }. useful writing format uses lot braces, LaTeX. (#23) collapse() now returns 0 length output given 0 length input (#28).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-0009000","dir":"Changelog","previous_headings":"","what":"glue 0.0.0.9000","title":"glue 0.0.0.9000","text":"Fix glue() admit . embedded expression string (#15, @egnha). Added NEWS.md file track changes package.","code":""}] +[{"path":[]},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://glue.tidyverse.org/dev/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to glue","title":"Contributing to glue","text":"outlines propose change glue. detailed info contributing , tidyverse packages, please see development contributing guide.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to glue","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to glue","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed).","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to glue","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"batpigandme/glue\", fork = TRUE). Install development dependences devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to glue","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://glue.tidyverse.org/dev/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to glue","text":"Please note glue project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://glue.tidyverse.org/dev/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2023 glue authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"current-state","dir":"","previous_headings":"","what":"Current state","title":"NA","text":"Glue currently stable, used installed quite extensively relatively issues reported. issues reported tend center around glue_sql().","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"known-outstanding-issues","dir":"","previous_headings":"","what":"Known outstanding issues","title":"NA","text":"think need way optionally disable interpretation quotes, fix https://github.com/r-lib/cli/issues/370, long standing https://github.com/tidyverse/glue/issues/158 Possibly loading closing blank line behaviors tweaked, issues brought https://github.com/tidyverse/glue/issues/234 natural. may difficult maintaining backwards compatibility.","code":""},{"path":"https://glue.tidyverse.org/dev/MAINTENANCE.html","id":"future-directions","dir":"","previous_headings":"","what":"Future directions","title":"NA","text":"include built-support custom numeric formats, suggested https://github.com/tidyverse/glue/issues/87 https://github.com/tidyverse/glue/issues/86? now avoided , common pain point glue Potentially revisit use custom glue class, gather also causes people grief practice?","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with glue","title":"Getting help with glue","text":"Thanks using glue! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with glue","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty insane ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with glue","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://glue.tidyverse.org/dev/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with glue","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"glue-engine","dir":"Articles","previous_headings":"","what":"glue engine","title":"glue custom knitr language engines","text":"first engine glue engine, evaluates chunk contents glue template. Maybe useful use glue engine set knitr option results = 'asis' output markdown HTML directly document.","code":"1 + 1 = {1 + 1} ## 1 + 1 = 2 ```{glue, results = 'asis', echo = FALSE} #### mtcars has **{nrow(mtcars)} rows** and _{ncol(mtcars)} columns_. ```"},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"mtcars-has-32-rows-and-11-columns-","dir":"Articles","previous_headings":"glue engine","what":"mtcars has 32 rows and 11 columns.","title":"glue custom knitr language engines","text":"want pass additional arguments glue call, simply include chunk options. median waiting time eruptions 76.","code":"```{glue, .open = \"<<\", .close = \">>\", results = 'asis', echo = FALSE} The **median waiting time** between eruptions is <>. ```"},{"path":"https://glue.tidyverse.org/dev/articles/engines.html","id":"glue_sql-engine","dir":"Articles","previous_headings":"","what":"glue_sql engine","title":"glue custom knitr language engines","text":"second engine glue_sql, use glue::glue_sql() generate SQL query run query using sql engine. First create new connection -memory SQLite database, write new table . Next define variables can use glue interpolate. can use glue_sql construct run query using variables database. Note need provide connection object connection chunk option. example two type quotes. first bare backtick, passed directly SQL engine unchanged. second backticks inside braces, specially interpreted proper quoting given SQL engine glue. example use sqlite engine, uses backticks quoting, use backticks inside brace syntax postgreSQL, glue_sql() automatically use double quotes quoting instead. Displaying records 1 - 10","code":"con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") mtcars$model <- rownames(mtcars) DBI::dbWriteTable(con, \"mtcars\", mtcars) var <- \"mpg\" tbl <- \"mtcars\" num <- 150 ```{glue_sql, connection = con} SELECT `model`, `hp`, {`var`} FROM {`tbl`} WHERE {`tbl`}.`hp` > {num} ``` SELECT `model`, `hp`, `mpg` FROM `mtcars` WHERE `mtcars`.`hp` > 150"},{"path":"https://glue.tidyverse.org/dev/articles/speed.html","id":"simple-concatenation","dir":"Articles","previous_headings":"","what":"Simple concatenation","title":"Speed of glue","text":"glue() slower paste0 sprintf(), twice fast gstring(), rprintf(). Although paste0() sprintf() don’t string interpolation likely always significantly faster glue, glue never meant direct replacement . rprintf::rprintf() variable interpolation, arbitrary expressions, one explicit goals writing glue. glue ~2x fast function (gstring()), roughly equivalent functionality. also still quite fast, 8000 evaluations per second machine.","code":"bar <- \"baz\" simple <- bench::mark( glue = as.character(glue::glue(\"foo{bar}\")), gstring = R.utils::gstring(\"foo${bar}\"), paste0 = paste0(\"foo\", bar), sprintf = sprintf(\"foo%s\", bar), rprintf = rprintf::rprintf(\"foo$bar\", bar = bar) ) simple %>% select(expression:total_time) %>% arrange(median) #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> #> 1 sprintf 761.12ns 872.07ns 1086458. 0B 0 #> 2 paste0 1.49µs 1.65µs 566993. 0B 56.7 #> 3 glue 101.3µs 107.23µs 9050. 139.63KB 30.2 #> 4 gstring 227.02µs 238.4µs 4053. 2.45MB 19.2 #> 5 rprintf 279.6µs 287.26µs 3422. 78.14KB 10.4 # plotting function defined in a hidden chunk plot_comparison(simple)"},{"path":"https://glue.tidyverse.org/dev/articles/speed.html","id":"vectorized-performance","dir":"Articles","previous_headings":"","what":"Vectorized performance","title":"Speed of glue","text":"Taking advantage glue’s vectorization best way improve performance. vectorized form previous benchmark, glue’s performance much closer paste0() sprintf().","code":"bar <- rep(\"bar\", 1e5) vectorized <- bench::mark( glue = as.character(glue::glue(\"foo{bar}\")), gstring = R.utils::gstring(\"foo${bar}\"), paste0 = paste0(\"foo\", bar), sprintf = sprintf(\"foo%s\", bar), rprintf = rprintf::rprintf(\"foo$bar\", bar = bar) ) vectorized %>% select(expression:total_time) %>% arrange(median) #> # A tibble: 5 × 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> #> 1 paste0 8.33ms 8.35ms 119. 781.3KB 4.18 #> 2 sprintf 9.57ms 9.86ms 101. 781.3KB 4.23 #> 3 gstring 11.25ms 11.35ms 88.0 1.53MB 6.44 #> 4 glue 12.7ms 13.28ms 73.6 2.29MB 6.49 #> 5 rprintf 28.06ms 28.39ms 35.2 3.05MB 4.40 # plotting function defined in a hidden chunk plot_comparison(vectorized)"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"collapse-transformer","dir":"Articles","previous_headings":"","what":"collapse transformer","title":"Transformers","text":"transformer automatically collapses glue block ending *.","code":"collapse_transformer <- function(regex = \"[*]$\", ...) { function(text, envir) { collapse <- grepl(regex, text) if (collapse) { text <- sub(regex, \"\", text) } res <- identity_transformer(text, envir) if (collapse) { glue_collapse(res, ...) } else { res } } } glue(\"{1:5*}\\n{letters[1:5]*}\", .transformer = collapse_transformer(sep = \", \")) #> 1, 2, 3, 4, 5 #> a, b, c, d, e glue(\"{1:5*}\\n{letters[1:5]*}\", .transformer = collapse_transformer(sep = \", \", last = \" and \")) #> 1, 2, 3, 4 and 5 #> a, b, c, d and e x <- c(\"one\", \"two\") glue(\"{x}: {1:5*}\", .transformer = collapse_transformer(sep = \", \")) #> one: 1, 2, 3, 4, 5 #> two: 1, 2, 3, 4, 5"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"shell-quoting-transformer","dir":"Articles","previous_headings":"","what":"Shell quoting transformer","title":"Transformers","text":"transformer automatically quotes variables use shell commands, e.g. via system() system2().","code":"shell_transformer <- function(type = c(\"sh\", \"csh\", \"cmd\", \"cmd2\")) { type <- match.arg(type) function(text, envir) { res <- identity_transformer(text, envir) shQuote(res) } } glue_sh <- function(..., .envir = parent.frame(), .type = c(\"sh\", \"csh\", \"cmd\", \"cmd2\")) { .type <- match.arg(.type) glue(..., .envir = .envir, .transformer = shell_transformer(.type)) } filename <- \"test\" writeLines(con = filename, \"hello!\") command <- glue_sh(\"cat {filename}\") command #> cat 'test' system(command)"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"emoji-transformer","dir":"Articles","previous_headings":"","what":"emoji transformer","title":"Transformers","text":"transformer converts text equivalent emoji.","code":"emoji_transformer <- function(text, envir) { if (grepl(\"[*]$\", text)) { text <- sub(\"[*]$\", \"\", text) glue_collapse(ji_find(text)$emoji) } else { ji(text) } } glue_ji <- function(..., .envir = parent.frame()) { glue(..., .open = \":\", .close = \":\", .envir = .envir, .transformer = emoji_transformer) } glue_ji(\"one :heart:\") glue_ji(\"many :heart*:\")"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"sprintf-transformer","dir":"Articles","previous_headings":"","what":"sprintf transformer","title":"Transformers","text":"transformer allows succinct sprintf format strings.","code":"sprintf_transformer <- function(text, envir) { m <- regexpr(\":.+$\", text) if (m != -1) { format <- substring(regmatches(text, m), 2) regmatches(text, m) <- \"\" res <- identity_transformer(text, envir) do.call(sprintf, list(glue(\"%{format}\"), res)) } else { identity_transformer(text, envir) } } glue_fmt <- function(..., .envir = parent.frame()) { glue(..., .transformer = sprintf_transformer, .envir = .envir) } glue_fmt(\"π = {pi:.3f}\") #> π = 3.142"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"signif-transformer","dir":"Articles","previous_headings":"","what":"signif transformer","title":"Transformers","text":"transformer generator represents numbers given number significant digits. useful want represent numbers using significant digits","code":"signif_transformer <- function(digits = 3) { force(digits) function(text, envir) { x <- identity_transformer(text, envir) if (is.numeric(x)) { signif(x, digits = digits) } else { x } } } glue_signif <- function(..., .envir = parent.frame()) { glue(..., .transformer = signif_transformer(3), .envir = .envir) } glue_signif(\"π = {pi}; 10π = {10*pi}; 100π = {100*pi}\") #> π = 3.14; 10π = 31.4; 100π = 314"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"safely-transformer","dir":"Articles","previous_headings":"","what":"safely transformer","title":"Transformers","text":"transformer acts like purrr::safely(), returns value instead error.","code":"safely_transformer <- function(otherwise = NA) { function(text, envir) { tryCatch( identity_transformer(text, envir), error = function(e) if (is.language(otherwise)) eval(otherwise) else otherwise) } } glue_safely <- function(..., .otherwise = NA, .envir = parent.frame()) { glue(..., .transformer = safely_transformer(.otherwise), .envir = .envir) } # Default returns missing if there is an error glue_safely(\"foo: {xyz}\") #> foo: NA # Or an empty string glue_safely(\"foo: {xyz}\", .otherwise = \"Error\") #> foo: Error # Or output the error message in red library(crayon) glue_safely(\"foo: {xyz}\", .otherwise = quote(glue(\"{red}Error: {conditionMessage(e)}{reset}\"))) #> foo: Error: Failed to evaluate glue component {xyz} #> Caused by error: #> ! object 'xyz' not found"},{"path":"https://glue.tidyverse.org/dev/articles/transformers.html","id":"variables-and-values-transformer","dir":"Articles","previous_headings":"","what":"“Variables and Values” transformer","title":"Transformers","text":"transformer expands input form {var_name=} var_name = var_value, .e. shorthand exposing variable names values. inspired f-strings feature coming Python 3.8. ’s actually general: can use expression input {expr=}.","code":"vv_transformer <- function(text, envir) { regex <- \"=$\" if (!grepl(regex, text)) { return(identity_transformer(text, envir)) } text <- sub(regex, \"\", text) res <- identity_transformer(text, envir) n <- length(res) res <- glue_collapse(res, sep = \", \") if (n > 1) { res <- c(\"[\", res, \"]\") } glue_collapse(c(text, \" = \", res)) } set.seed(1234) description <- \"some random\" numbers <- sample(100, 4) average <- mean(numbers) sum <- sum(numbers) glue(\"For {description} {numbers=}, {average=}, {sum=}.\", .transformer = vv_transformer) #> For some random numbers = [28, 80, 22, 9], average = 34.75, sum = 139. a <- 3 b <- 5.6 glue(\"{a=}\\n{b=}\\n{a * 9 + b * 2=}\", .transformer = vv_transformer) #> a = 3 #> b = 5.6 #> a * 9 + b * 2 = 38.2"},{"path":"https://glue.tidyverse.org/dev/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Jim Hester. Author. Jennifer Bryan. Author, maintainer. . Copyright holder, funder.","code":""},{"path":"https://glue.tidyverse.org/dev/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Hester J, Bryan J (2024). glue: Interpreted String Literals. R package version 1.7.0.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/.","code":"@Manual{, title = {glue: Interpreted String Literals}, author = {Jim Hester and Jennifer Bryan}, year = {2024}, note = {R package version 1.7.0.9000, https://github.com/tidyverse/glue}, url = {https://glue.tidyverse.org/}, }"},{"path":[]},{"path":"https://glue.tidyverse.org/dev/index.html","id":"overview","dir":"","previous_headings":"","what":"Overview","title":"Interpreted String Literals","text":"Glue offers interpreted string literals small, fast, dependency-free. Glue embedding R expressions curly braces evaluated inserted argument string.","code":""},{"path":"https://glue.tidyverse.org/dev/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Interpreted String Literals","text":"","code":"# Install development version from GitHub pak::pak(\"tidyverse/glue\")"},{"path":[]},{"path":"https://glue.tidyverse.org/dev/index.html","id":"variables-can-be-passed-directly-into-strings","dir":"","previous_headings":"Usage","what":"Variables can be passed directly into strings.","title":"Interpreted String Literals","text":"Note glue::glue() also made available via stringr::str_glue(). ’ve already attached stringr (perhaps whole tidyverse), can access glue() like :","code":"library(glue) name <- \"Fred\" glue('My name is {name}.') #> My name is Fred. library(stringr) # or library(tidyverse) stringr_fcn <- \"`stringr::str_glue()`\" glue_fcn <- \"`glue::glue()`\" str_glue('{stringr_fcn} is essentially an alias for {glue_fcn}.') #> `stringr::str_glue()` is essentially an alias for `glue::glue()`."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"long-strings-are-broken-by-line-and-concatenated-together","dir":"","previous_headings":"Usage","what":"Long strings are broken by line and concatenated together.","title":"Interpreted String Literals","text":"","code":"library(glue) name <- \"Fred\" age <- 50 anniversary <- as.Date(\"1991-10-12\") glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.') #> My name is Fred, my age next year is 51, my anniversary is Saturday, October 12, 1991."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"named-arguments-are-used-to-assign-temporary-variables","dir":"","previous_headings":"Usage","what":"Named arguments are used to assign temporary variables.","title":"Interpreted String Literals","text":"","code":"glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.', name = \"Joe\", age = 40, anniversary = as.Date(\"2001-10-12\")) #> My name is Joe, my age next year is 41, my anniversary is Friday, October 12, 2001."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue_data-is-useful-with-magrittr-pipes","dir":"","previous_headings":"Usage","what":"glue_data() is useful with magrittr pipes.","title":"Interpreted String Literals","text":"","code":"`%>%` <- magrittr::`%>%` head(mtcars) %>% glue_data(\"{rownames(.)} has {hp} hp\") #> Mazda RX4 has 110 hp #> Mazda RX4 Wag has 110 hp #> Datsun 710 has 93 hp #> Hornet 4 Drive has 110 hp #> Hornet Sportabout has 175 hp #> Valiant has 105 hp"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue-is-useful-within-dplyr-pipelines","dir":"","previous_headings":"Usage","what":"glue() is useful within dplyr pipelines","title":"Interpreted String Literals","text":"","code":"library(dplyr) head(iris) %>% mutate(description = glue(\"This {Species} has a petal length of {Petal.Length}\")) #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa #> description #> 1 This setosa has a petal length of 1.4 #> 2 This setosa has a petal length of 1.4 #> 3 This setosa has a petal length of 1.3 #> 4 This setosa has a petal length of 1.5 #> 5 This setosa has a petal length of 1.4 #> 6 This setosa has a petal length of 1.7"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"leading-whitespace-and-blank-lines-from-the-first-and-last-lines-are-automatically-trimmed","dir":"","previous_headings":"Usage","what":"Leading whitespace and blank lines from the first and last lines are automatically trimmed.","title":"Interpreted String Literals","text":"lets indent strings naturally code.","code":"glue(\" A formatted string Can have multiple lines with additional indention preserved \") #> A formatted string #> Can have multiple lines #> with additional indention preserved"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"an-additional-newline-can-be-used-if-you-want-a-leading-or-trailing-newline","dir":"","previous_headings":"Usage","what":"An additional newline can be used if you want a leading or trailing newline.","title":"Interpreted String Literals","text":"","code":"glue(\" leading or trailing newlines can be added explicitly \") #> #> leading or trailing newlines can be added explicitly"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"id_-at-the-end-of-a-line-continues-it-without-a-new-line","dir":"","previous_headings":"Usage","what":"\\\\ at the end of a line continues it without a new line.","title":"Interpreted String Literals","text":"","code":"glue(\" A formatted string \\\\ can also be on a \\\\ single line \") #> A formatted string can also be on a single line"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"a-literal-brace-is-inserted-by-using-doubled-braces","dir":"","previous_headings":"Usage","what":"A literal brace is inserted by using doubled braces.","title":"Interpreted String Literals","text":"","code":"name <- \"Fred\" glue(\"My name is {name}, not {{name}}.\") #> My name is Fred, not {name}."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"alternative-delimiters-can-be-specified-with-open-and-close","dir":"","previous_headings":"Usage","what":"Alternative delimiters can be specified with .open and .close.","title":"Interpreted String Literals","text":"","code":"one <- \"1\" glue(\"The value of $e^{2\\\\pi i}$ is $<>$.\", .open = \"<<\", .close = \">>\") #> The value of $e^{2\\pi i}$ is $1$."},{"path":"https://glue.tidyverse.org/dev/index.html","id":"all-valid-r-code-works-in-expressions-including-braces-and-escaping","dir":"","previous_headings":"Usage","what":"All valid R code works in expressions, including braces and escaping.","title":"Interpreted String Literals","text":"Backslashes need doubled just like R strings.","code":"`foo}\\`` <- \"foo\" glue(\"{ { '}\\\\'' # { and } in comments, single quotes \\\"}\\\\\\\"\\\" # or double quotes are ignored `foo}\\\\`` # as are { in backticks } }\") #> foo"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"glue_sql-makes-constructing-sql-statements-safe-and-easy","dir":"","previous_headings":"Usage","what":"glue_sql() makes constructing SQL statements safe and easy","title":"Interpreted String Literals","text":"Use backticks quote identifiers, normal strings numbers quoted appropriately backend.","code":"library(glue) con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") colnames(iris) <- gsub(\"[.]\", \"_\", tolower(colnames(iris))) DBI::dbWriteTable(con, \"iris\", iris) var <- \"sepal_width\" tbl <- \"iris\" num <- 2 val <- \"setosa\" glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {num} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > 2 #> AND `iris`.species = 'setosa' # `glue_sql()` can be used in conjunction with parameterized queries using # `DBI::dbBind()` to provide protection for SQL Injection attacks sql <- glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > ? \", .con = con) query <- DBI::dbSendQuery(con, sql) DBI::dbBind(query, list(num)) DBI::dbFetch(query, n = 4) #> sepal_width #> 1 3.5 #> 2 3.0 #> 3 3.2 #> 4 3.1 DBI::dbClearResult(query) # `glue_sql()` can be used to build up more complex queries with # interchangeable sub queries. It returns `DBI::SQL()` objects which are # properly protected from quoting. sub_query <- glue_sql(\" SELECT * FROM {`tbl`} \", .con = con) glue_sql(\" SELECT s.{`var`} FROM ({sub_query}) AS s \", .con = con) #> SELECT s.`sepal_width` #> FROM (SELECT * #> FROM `iris`) AS s # If you want to input multiple values for use in SQL IN statements put `*` # at the end of the value and the values will be collapsed and quoted appropriately. glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1) glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1:5, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1, 2, 3, 4, 5) glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = \"setosa\", .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa') glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = c(\"setosa\", \"versicolor\"), .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa', 'versicolor')"},{"path":"https://glue.tidyverse.org/dev/index.html","id":"other-implementations","dir":"","previous_headings":"","what":"Other implementations","title":"Interpreted String Literals","text":"implementations string interpolation R (although using identical syntax). stringr::str_interp R.utils::gstring rprintf String templating closely related string interpolation, although exactly concept. packages implementing string templating R include. whisker brew jinjar","code":""},{"path":"https://glue.tidyverse.org/dev/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Interpreted String Literals","text":"Please note glue project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":null,"dir":"Reference","previous_headings":"","what":"Coerce object to glue — as_glue","title":"Coerce object to glue — as_glue","text":"glue object character vector S3 class \"glue\". \"glue\" class implements print method shows literal contents (rather string implementation) + method, can concatenate addition operator.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coerce object to glue — as_glue","text":"","code":"as_glue(x, ...)"},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coerce object to glue — as_glue","text":"x object coerced. ... arguments passed methods.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coerce object to glue — as_glue","text":"character vector S3 class \"glue\".","code":""},{"path":"https://glue.tidyverse.org/dev/reference/as_glue.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coerce object to glue — as_glue","text":"","code":"x <- as_glue(c(\"abc\", \"\\\"\\\\\\\\\", \"\\n\")) x #> abc #> \"\\\\ #> #> x <- 1 y <- 3 glue(\"x + y\") + \" = {x + y}\" #> x + y = {x + y}"},{"path":"https://glue.tidyverse.org/dev/reference/glue-deprecated.html","id":null,"dir":"Reference","previous_headings":"","what":"Deprecated Functions — glue-deprecated","title":"Deprecated Functions — glue-deprecated","text":"functions Deprecated release glue, removed future version.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":null,"dir":"Reference","previous_headings":"","what":"Format and interpolate a string — glue","title":"Format and interpolate a string — glue","text":"Expressions enclosed braces evaluated R code. Long strings broken line concatenated together. Leading whitespace blank lines first last lines automatically trimmed.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format and interpolate a string — glue","text":"","code":"glue_data( .x, ..., .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = \"NA\", .null = character(), .comment = \"#\", .literal = FALSE, .transformer = identity_transformer, .trim = TRUE ) glue( ..., .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = \"NA\", .null = character(), .comment = \"#\", .literal = FALSE, .transformer = identity_transformer, .trim = TRUE )"},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format and interpolate a string — glue","text":".x [listish] environment, list, data frame used lookup values. ... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .sep [character(1): ‘\"\"’] Separator used separate elements. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .open [character(1): ‘\\{’] opening delimiter. Doubling full delimiter escapes . .close [character(1): ‘\\}’] closing delimiter. Doubling full delimiter escapes . .na [character(1): ‘NA’] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .null [character(1): ‘character()’] Value replace NULL values . character() whole output character(). NULL NULL values dropped (paste0()). Otherwise value replaced value .null. .comment [character(1): ‘#’] Value use comment character. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .transformer [function] function taking two arguments, text envir, text unparsed string inside glue block envir execution environment. .transformer lets modify glue block , , evaluation, allowing create custom glue()-like functions. See vignette(\"transformers\") examples. .trim [logical(1): ‘TRUE’] Whether trim input template trim() .","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format and interpolate a string — glue","text":"glue object, created as_glue().","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/glue.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format and interpolate a string — glue","text":"","code":"name <- \"Fred\" age <- 50 anniversary <- as.Date(\"1991-10-12\") glue('My name is {name},', 'my age next year is {age + 1},', 'my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.') #> My name is Fred,my age next year is 51,my anniversary is Saturday, October 12, 1991. # single braces can be inserted by doubling them glue(\"My name is {name}, not {{name}}.\") #> My name is Fred, not {name}. # Named arguments can be used to assign temporary variables. glue('My name is {name},', ' my age next year is {age + 1},', ' my anniversary is {format(anniversary, \"%A, %B %d, %Y\")}.', name = \"Joe\", age = 40, anniversary = as.Date(\"2001-10-12\")) #> My name is Joe, my age next year is 41, my anniversary is Friday, October 12, 2001. # `glue()` can also be used in user defined functions intro <- function(name, profession, country){ glue(\"My name is {name}, a {profession}, from {country}\") } intro(\"Shelmith\", \"Senior Data Analyst\", \"Kenya\") #> My name is Shelmith, a Senior Data Analyst, from Kenya intro(\"Cate\", \"Data Scientist\", \"Kenya\") #> My name is Cate, a Data Scientist, from Kenya # `glue_data()` is useful in magrittr pipes if (require(magrittr)) { mtcars %>% glue_data(\"{rownames(.)} has {hp} hp\") # Or within dplyr pipelines if (require(dplyr)) { head(iris) %>% mutate(description = glue(\"This {Species} has a petal length of {Petal.Length}\")) }} #> Loading required package: magrittr #> Loading required package: 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 #> Sepal.Length Sepal.Width Petal.Length Petal.Width Species #> 1 5.1 3.5 1.4 0.2 setosa #> 2 4.9 3.0 1.4 0.2 setosa #> 3 4.7 3.2 1.3 0.2 setosa #> 4 4.6 3.1 1.5 0.2 setosa #> 5 5.0 3.6 1.4 0.2 setosa #> 6 5.4 3.9 1.7 0.4 setosa #> description #> 1 This setosa has a petal length of 1.4 #> 2 This setosa has a petal length of 1.4 #> 3 This setosa has a petal length of 1.3 #> 4 This setosa has a petal length of 1.5 #> 5 This setosa has a petal length of 1.4 #> 6 This setosa has a petal length of 1.7 # Alternative delimiters can also be used if needed one <- \"1\" glue(\"The value of $e^{2\\\\pi i}$ is $<>$.\", .open = \"<<\", .close = \">>\") #> The value of $e^{2\\pi i}$ is $1$."},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":null,"dir":"Reference","previous_headings":"","what":"Construct strings with color — glue_col","title":"Construct strings with color — glue_col","text":"crayon package defines number functions used color terminal output. glue_col() glue_data_col() functions provide additional syntax make using functions glue strings easier. Using following syntax apply function crayon::blue() text 'foo bar'. want expression evaluated, simply place normal brace expression (can nested). text want color contains, e.g., unpaired quote comment character, specify .literal = TRUE.","code":"{blue foo bar} {blue 1 + 1 = {1 + 1}}"},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Construct strings with color — glue_col","text":"","code":"glue_col(..., .envir = parent.frame(), .na = \"NA\", .literal = FALSE) glue_data_col(.x, ..., .envir = parent.frame(), .na = \"NA\", .literal = FALSE)"},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Construct strings with color — glue_col","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .na [character(1): ‘NA’] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Construct strings with color — glue_col","text":"glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_col.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Construct strings with color — glue_col","text":"","code":"library(crayon) glue_col(\"{blue foo bar}\") #> foo bar glue_col(\"{blue 1 + 1 = {1 + 1}}\") #> 1 + 1 = 2 glue_col(\"{blue 2 + 2 = {green {2 + 2}}}\") #> 2 + 2 = 4 white_on_black <- bgBlack $ white glue_col(\"{white_on_black Roses are {red {colors()[[552]]}}, Violets are {blue {colors()[[26]]}}, `glue_col()` can show \\\\ {red c}{yellow o}{green l}{cyan o}{blue r}{magenta s} and {bold bold} and {underline underline} too! }\") #> Roses are red, #> Violets are blue, #> `glue_col()` can show colors #> and bold and underline too! # this would error due to an unterminated quote, if we did not specify # `.literal = TRUE` glue_col(\"{yellow It's} happening!\", .literal = TRUE) #> It's happening! # `.literal = TRUE` also prevents an error here due to the `#` comment glue_col( \"A URL: {magenta https://github.com/tidyverse/glue#readme}\", .literal = TRUE ) #> A URL: https://github.com/tidyverse/glue#readme # `.literal = TRUE` does NOT prevent evaluation x <- \"world\" y <- \"day\" glue_col(\"hello {x}! {green it's a new {y}!}\", .literal = TRUE) #> hello world! it's a new day!"},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":null,"dir":"Reference","previous_headings":"","what":"Collapse a character vector — glue_collapse","title":"Collapse a character vector — glue_collapse","text":"glue_collapse() collapses character vector length length 1 vector. glue_sql_collapse() returns [DBI::SQL()] object rather glue object.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Collapse a character vector — glue_collapse","text":"","code":"glue_collapse(x, sep = \"\", width = Inf, last = \"\") glue_sql_collapse(x, sep = \"\", width = Inf, last = \"\")"},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Collapse a character vector — glue_collapse","text":"x character vector collapse. sep character string separate terms. NA_character_. width maximum string width truncating .... last String used separate last two items x least 2 items.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Collapse a character vector — glue_collapse","text":"Always returns length-1 glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_collapse.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Collapse a character vector — glue_collapse","text":"","code":"glue_collapse(glue(\"{1:10}\")) #> 12345678910 # Wide values can be truncated glue_collapse(glue(\"{1:10}\"), width = 5) #> 12... glue_collapse(1:4, \", \", last = \" and \") #> 1, 2, 3 and 4"},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":null,"dir":"Reference","previous_headings":"","what":"Safely interpolate strings — glue_safe","title":"Safely interpolate strings — glue_safe","text":"glue_safe() glue_data_safe() differ glue() glue_data() safe versions look symbols environment using get(). execute R code. makes suitable use untrusted input, inputs Shiny application, using normal functions allow attacker execute arbitrary code.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Safely interpolate strings — glue_safe","text":"","code":"glue_safe(..., .envir = parent.frame()) glue_data_safe(.x, ..., .envir = parent.frame())"},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Safely interpolate strings — glue_safe","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Safely interpolate strings — glue_safe","text":"glue object, created as_glue().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_safe.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Safely interpolate strings — glue_safe","text":"","code":"\"1 + 1\" <- 5 # glue actually executes the code glue(\"{1 + 1}\") #> 2 # glue_safe just looks up the value glue_safe(\"{1 + 1}\") #> 5 rm(\"1 + 1\")"},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":null,"dir":"Reference","previous_headings":"","what":"Interpolate strings with SQL escaping — glue_sql","title":"Interpolate strings with SQL escaping — glue_sql","text":"SQL databases often custom quotation syntax identifiers strings make writing SQL queries error prone cumbersome . glue_sql() glue_data_sql() analogs glue() glue_data() handle SQL quoting. glue_sql_collapse() can used collapse DBI::SQL() objects. automatically quote character results, quote identifiers glue expression surrounded backticks '`' quote non-characters numbers. numeric data stored character column (quoted) pass data glue_sql() character. Returning result DBI::SQL() suppress quoting desired given value. Note parameterized queries generally safest efficient way pass user defined values query, however every database driver supports . place * end glue expression values collapsed commas. useful SQL Operator instance.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Interpolate strings with SQL escaping — glue_sql","text":"","code":"glue_sql( ..., .con, .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = DBI::SQL(\"NULL\"), .null = character(), .comment = \"#\", .literal = FALSE, .trim = TRUE ) glue_data_sql( .x, ..., .con, .sep = \"\", .envir = parent.frame(), .open = \"{\", .close = \"}\", .na = DBI::SQL(\"NULL\"), .null = character(), .comment = \"#\", .literal = FALSE, .trim = TRUE )"},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Interpolate strings with SQL escaping — glue_sql","text":"... [expressions] Unnamed arguments taken expression string(s) format. Multiple inputs concatenated together formatting. Named arguments taken temporary variables available substitution. .con [DBIConnection]: DBI connection object obtained DBI::dbConnect(). .sep [character(1): ‘\"\"’] Separator used separate elements. .envir [environment: parent.frame()] Environment evaluate expression . Expressions evaluated left right. .x environment, expressions evaluated environment .envir ignored. NULL passed, equivalent emptyenv(). .open [character(1): ‘\\{’] opening delimiter. Doubling full delimiter escapes . .close [character(1): ‘\\}’] closing delimiter. Doubling full delimiter escapes . .na [character(1): DBI::SQL(\"NULL\")] Value replace NA values . NULL missing values propagated, NA result cause NA output. Otherwise value replaced value .na. .null [character(1): ‘character()’] Value replace NULL values . character() whole output character(). NULL NULL values dropped (paste0()). Otherwise value replaced value .null. .comment [character(1): ‘#’] Value use comment character. .literal [boolean(1): ‘FALSE’] Whether treat single double quotes, backticks, comments regular characters (vs. syntactic elements), parsing expression string. Setting .literal = TRUE probably makes sense combination custom .transformer, case glue_col(). Regard argument (especially, name) experimental. .trim [logical(1): ‘TRUE’] Whether trim input template trim() . .x [listish] environment, list, data frame used lookup values.","code":"For `glue_data()`, elements in `...` override the values in `.x`."},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Interpolate strings with SQL escaping — glue_sql","text":"DBI::SQL() object given query.","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/glue_sql.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Interpolate strings with SQL escaping — glue_sql","text":"","code":"con <- DBI::dbConnect(RSQLite::SQLite(), \":memory:\") iris2 <- iris colnames(iris2) <- gsub(\"[.]\", \"_\", tolower(colnames(iris))) DBI::dbWriteTable(con, \"iris\", iris2) var <- \"sepal_width\" tbl <- \"iris\" num <- 2 val <- \"setosa\" glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {num} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > 2 #> AND `iris`.species = 'setosa' # If sepal_length is store on the database as a character explicitly convert # the data to character to quote appropriately. glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > {as.character(num)} AND {`tbl`}.species = {val} \", .con = con) #> SELECT `sepal_width` #> FROM `iris` #> WHERE `iris`.sepal_length > '2' #> AND `iris`.species = 'setosa' # `glue_sql()` can be used in conjuction with parameterized queries using # `DBI::dbBind()` to provide protection for SQL Injection attacks sql <- glue_sql(\" SELECT {`var`} FROM {`tbl`} WHERE {`tbl`}.sepal_length > ? \", .con = con) query <- DBI::dbSendQuery(con, sql) DBI::dbBind(query, list(num)) DBI::dbFetch(query, n = 4) #> sepal_width #> 1 3.5 #> 2 3.0 #> 3 3.2 #> 4 3.1 DBI::dbClearResult(query) # `glue_sql()` can be used to build up more complex queries with # interchangeable sub queries. It returns `DBI::SQL()` objects which are # properly protected from quoting. sub_query <- glue_sql(\" SELECT * FROM {`tbl`} \", .con = con) glue_sql(\" SELECT s.{`var`} FROM ({sub_query}) AS s \", .con = con) #> SELECT s.`sepal_width` #> FROM (SELECT * #> FROM `iris`) AS s # If you want to input multiple values for use in SQL IN statements put `*` # at the end of the value and the values will be collapsed and quoted appropriately. glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1) glue_sql(\"SELECT * FROM {`tbl`} WHERE sepal_length IN ({vals*})\", vals = 1:5, .con = con) #> SELECT * FROM `iris` WHERE sepal_length IN (1, 2, 3, 4, 5) glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = \"setosa\", .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa') glue_sql(\"SELECT * FROM {`tbl`} WHERE species IN ({vals*})\", vals = c(\"setosa\", \"versicolor\"), .con = con) #> SELECT * FROM `iris` WHERE species IN ('setosa', 'versicolor') # If you need to reference variables from multiple tables use `DBI::Id()`. # Here we create a new table of nicknames, join the two tables together and # select columns from both tables. Using `DBI::Id()` and the special # `glue_sql()` syntax ensures all the table and column identifiers are quoted # appropriately. iris_db <- \"iris\" nicknames_db <- \"nicknames\" nicknames <- data.frame( species = c(\"setosa\", \"versicolor\", \"virginica\"), nickname = c(\"Beachhead Iris\", \"Harlequin Blueflag\", \"Virginia Iris\"), stringsAsFactors = FALSE ) DBI::dbWriteTable(con, nicknames_db, nicknames) cols <- list( DBI::Id(iris_db, \"sepal_length\"), DBI::Id(iris_db, \"sepal_width\"), DBI::Id(nicknames_db, \"nickname\") ) iris_species <- DBI::Id(iris_db, \"species\") nicknames_species <- DBI::Id(nicknames_db, \"species\") query <- glue_sql(\" SELECT {`cols`*} FROM {`iris_db`} JOIN {`nicknames_db`} ON {`iris_species`}={`nicknames_species`}\", .con = con ) query #> SELECT `iris`.`sepal_length`, `iris`.`sepal_width`, `nicknames`.`nickname` #> FROM `iris` #> JOIN `nicknames` #> ON `iris`.`species`=`nicknames`.`species` DBI::dbGetQuery(con, query, n = 5) #> sepal_length sepal_width nickname #> 1 5.1 3.5 Beachhead Iris #> 2 4.9 3.0 Beachhead Iris #> 3 4.7 3.2 Beachhead Iris #> 4 4.6 3.1 Beachhead Iris #> 5 5.0 3.6 Beachhead Iris DBI::dbDisconnect(con)"},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse and Evaluate R code — identity_transformer","title":"Parse and Evaluate R code — identity_transformer","text":"simple wrapper around eval(parse()), used default transformer.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse and Evaluate R code — identity_transformer","text":"","code":"identity_transformer(text, envir = parent.frame())"},{"path":"https://glue.tidyverse.org/dev/reference/identity_transformer.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse and Evaluate R code — identity_transformer","text":"text Text (typically) R code parse evaluate. envir environment evaluate code ","code":""},{"path":[]},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":null,"dir":"Reference","previous_headings":"","what":"Quoting operators — quoting","title":"Quoting operators — quoting","text":"functions make easy quote individual element useful conjunction glue_collapse(). thin wrappers around base::encodeString().","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Quoting operators — quoting","text":"","code":"single_quote(x) double_quote(x) backtick(x)"},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Quoting operators — quoting","text":"x character quote.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Quoting operators — quoting","text":"character vector length x, attributes (including names dimensions) class set. Marked UTF-8 encodings preserved.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/quoting.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Quoting operators — quoting","text":"","code":"x <- 1:5 glue('Values of x: {glue_collapse(backtick(x), sep = \", \", last = \" and \")}') #> Values of x: `1`, `2`, `3`, `4` and `5`"},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":null,"dir":"Reference","previous_headings":"","what":"Trim a character vector — trim","title":"Trim a character vector — trim","text":"trims character vector according trimming rules used glue. follow similar rules Python Docstrings, following features. Leading trailing whitespace first last lines removed. uniform amount indentation stripped second line , equal minimum indentation non-blank lines first. Lines can continued across newlines using \\\\.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Trim a character vector — trim","text":"","code":"trim(x)"},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Trim a character vector — trim","text":"x character vector trim.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Trim a character vector — trim","text":"character vector.","code":""},{"path":"https://glue.tidyverse.org/dev/reference/trim.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Trim a character vector — trim","text":"","code":"glue(\" A formatted string Can have multiple lines with additional indention preserved \") #> A formatted string #> Can have multiple lines #> with additional indention preserved glue(\" \\ntrailing or leading newlines can be added explicitly\\n \") #> #> trailing or leading newlines can be added explicitly #> glue(\" A formatted string \\\\ can also be on a \\\\ single line \") #> A formatted string can also be on a single line"},{"path":[]},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-170","dir":"Changelog","previous_headings":"","what":"glue 1.7.0","title":"glue 1.7.0","text":"CRAN release: 2024-01-09 rlang installed, glue generate informative errors interpolated expression either can’t parsed fails evaluate (#229). + now works situations, gives errors one side isn’t character vector. longer automatically applies glue interpolation non-glue input, one. ’ll need (#286). glue_collapse(character()) (hence glue_sql_collapse(character())) now return \"\", always return single string (#88). glue_sql() now collapses empty vector \"\" \"NULL\" (#272). glue_sql() now uses DBI::dbQuoteLiteral() object types. increase fidelity escaping different object types (#279). “Speed glue” vignette converted article, allows several package removed Suggests (re-located Config/Needs/website). code got light refresh, including switch microbenchmark bench modern use ggplot2. Add $(C_VISIBILITY) compiler flags hide internal symbols dll (#284 @lionel-).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-162","dir":"Changelog","previous_headings":"","what":"glue 1.6.2","title":"glue 1.6.2","text":"CRAN release: 2022-02-24 Modify test better forward compatibility R.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-161","dir":"Changelog","previous_headings":"","what":"glue 1.6.1","title":"glue 1.6.1","text":"CRAN release: 2022-01-22 glue now registers custom knitr engines way robust namespace-loading edge cases can arise package installation (#254).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-160","dir":"Changelog","previous_headings":"","what":"glue 1.6.0","title":"glue 1.6.0","text":"CRAN release: 2021-12-17 glue(), glue_data(), glue_col(), glue_data_col() gain new .literal argument, controls quotes comment character treated parsing expression string (#235). mostly useful using custom transformer. Trailing whitespace-lines don’t interfere indentation (#247).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-151","dir":"Changelog","previous_headings":"","what":"glue 1.5.1","title":"glue 1.5.1","text":"CRAN release: 2021-11-30 Jennifer Bryan now maintainer. existing custom language engines knitr, glue glue_sql, documented new vignette (#71). Detail added release: glue now sets registration engines .onLoad(). glue_col() gives special treatment styling functions crayon package, e.g. glue_col(\"{blue foo}\") “just works” now, even crayon attached (installed) (#241). Unterminated backticks trigger error unterminated single double quotes (#237). glue_sql() collapses zero-length DBI::SQL object DBI::SQL(\"NULL\") (#244 @shrektan).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-150","dir":"Changelog","previous_headings":"","what":"glue 1.5.0","title":"glue 1.5.0","text":"CRAN release: 2021-11-06","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"breaking-changes-1-5-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"glue 1.5.0","text":"Long deprecated function collapse() removed (#213)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"new-functions-and-arguments-1-5-0","dir":"Changelog","previous_headings":"","what":"New functions and arguments","title":"glue 1.5.0","text":"New glue_sql_collapse() function collapse inputs return DBI::SQL() object (#103). glue() gains new .comment argument, control comment character (#193). glue() gains new .null argument, control value replace NULL values (#217, @echasnovski).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-5-0","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.5.0","text":"sql_quote_transformer() now allows whitespace trailing * (#218). compare_proxy.glue() method defined glue objects can compared strings testthat 3e without errors (#212) print.glue() longer prints empty newline 0 length inputs (#214) Unterminated comments glue expression now throw error (#227, @gaborcsardi) Unterminated quotes glue expressions now throw error (#226, @gaborcsardi)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-142","dir":"Changelog","previous_headings":"","what":"glue 1.4.2","title":"glue 1.4.2","text":"CRAN release: 2020-08-27 glue_safe() gives slightly nicer error message required version R now 3.2 (#189) glue_sql() now collapses DBI::SQL() elements correctly (#192 @shrektan) internal compare() method gains ... argument, compatibility testthat 3.0.0","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-141","dir":"Changelog","previous_headings":"","what":"glue 1.4.1","title":"glue 1.4.1","text":"CRAN release: 2020-05-13 Internal changes compatibility vctrs 0.3.0 (#187). glue_sql() now replaces missing values correctly collapsing values (#185). glue_sql() now always preserves type column even presence missing values (#130)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-140","dir":"Changelog","previous_headings":"","what":"glue 1.4.0","title":"glue 1.4.0","text":"CRAN release: 2020-04-03 .envir = NULL now supported equivalent passing .envir = emptyenv() (#140) New glue_safe() glue_data_safe() functions, safer versions glue() execute code, look values (using get()). alternatives useful things like shiny applications control input glue expressions. (#140) Fixed memory access issue memory leaks found valgrind.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-132","dir":"Changelog","previous_headings":"","what":"glue 1.3.2","title":"glue 1.3.2","text":"CRAN release: 2020-03-12 glue now implements vctrs methods. ensures vectors glue strings compatible tidyverse packages like tidyr (r-lib/tidyselect#170, tidyverse/tidyr#773, @lionel-). Fix LTO type mismatch warning (#146) glue_sql() now quotes lists values appropriate type, rather coercing values characters (#153) glue_data() now implicitly coerces .x list. glue() gains .trim argument, like glue_data(). single_quote() double_quote() backtick() return NA NA inputs (#135). Improve trim()’s handling lines containing indentation (#162, #163, @alandipert)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-131","dir":"Changelog","previous_headings":"","what":"glue 1.3.1","title":"glue 1.3.1","text":"CRAN release: 2019-03-12","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"features-1-3-1","dir":"Changelog","previous_headings":"","what":"Features","title":"glue 1.3.1","text":"glue() now + method combine strings. glue_sql() now collapses zero-length vector DBI::SQL(\"NULL\") (#134 @shrektan).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-3-1","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.3.1","text":"glue_sql() now supports unquoting lists Id objects. glue_sql() now quotes characters NAs appropriately (#115). glue_sql() now quotes Dates appropriately (#98). potential protection error reported rchk fixed.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-130","dir":"Changelog","previous_headings":"","what":"glue 1.3.0","title":"glue 1.3.0","text":"CRAN release: 2018-07-17","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"breaking-changes-1-3-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"glue 1.3.0","text":"evaluate() function removed. Changes elsewhere glue made implementation trivial removed sake clarity. Previous uses can replaced eval(parse(text = text), envir). collapse() renamed glue_collapse() avoid namespace collisions dplyr::collapse().","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"features-1-3-0","dir":"Changelog","previous_headings":"","what":"Features","title":"glue 1.3.0","text":"compare.glue() added, make easier use glue objects testthat::expect_equal() statements. glue_col() glue_data_col() functions added display strings color.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"bugfixes-and-minor-changes-1-3-0","dir":"Changelog","previous_headings":"","what":"Bugfixes and minor changes","title":"glue 1.3.0","text":"Glue now throws informative error message interpolate function string (#114, @haleyjeppson & @ijlyttle). Glue now evaluates unnamed arguments lazily delayedAssign(), performance cost argument used. (#83, @egnha). Fixed bug names assigned expression interpolation variable conflict name variable (#89, @egnha). drop glue class subsetting (#66). Fix glue() collapse() always return UTF-8 encoded strings (#81, @dpprdan)","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-120","dir":"Changelog","previous_headings":"","what":"glue 1.2.0","title":"glue 1.2.0","text":"CRAN release: 2017-10-29 implementation tweaked slightly faster cases. glue() now .transformer argument, allows use custom logic evaluate code within glue blocks. See vignette(\"transformers\") details example transformer functions. glue() now returns NA results NA .na NULL. Otherwise NA values replaced value .na. trim() use trimming logic glue now exported. glue_sql() glue_data_sql() functions added make constructing SQL statements glue safer easier. glue() now easier use used within helper functions lapply. Fix last expression glue() NULL.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-111","dir":"Changelog","previous_headings":"","what":"glue 1.1.1","title":"glue 1.1.1","text":"CRAN release: 2017-06-21 Another fix PROTECT / REPROTECT found rchk static analyzer.","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-110","dir":"Changelog","previous_headings":"","what":"glue 1.1.0","title":"glue 1.1.0","text":"CRAN release: 2017-06-13 Fix PROTECT errors resizing output strings. glue() always returns ‘UTF-8’ strings, converting inputs encodings needed. () to_data() removed. glue() glue_data() can now take alternative delimiters { }. useful writing format uses lot braces, LaTeX. (#23) collapse() now returns 0 length output given 0 length input (#28).","code":""},{"path":"https://glue.tidyverse.org/dev/news/index.html","id":"glue-0009000","dir":"Changelog","previous_headings":"","what":"glue 0.0.0.9000","title":"glue 0.0.0.9000","text":"Fix glue() admit . embedded expression string (#15, @egnha). Added NEWS.md file track changes package.","code":""}]
Source: DESCRIPTION
DESCRIPTION
Hester J, Bryan J (2023). +
Hester J, Bryan J (2024). glue: Interpreted String Literals. -R package version 1.6.2.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/. +R package version 1.7.0.9000, https://github.com/tidyverse/glue, https://glue.tidyverse.org/.
@Manual{, title = {glue: Interpreted String Literals}, author = {Jim Hester and Jennifer Bryan}, - year = {2023}, - note = {R package version 1.6.2.9000, https://github.com/tidyverse/glue}, + year = {2024}, + note = {R package version 1.7.0.9000, https://github.com/tidyverse/glue}, url = {https://glue.tidyverse.org/}, }
CRAN release: 2024-01-09
If rlang is installed, glue will generate more informative errors if an interpolated expression either can’t be parsed or fails to evaluate (#229).
+ now works in more situations, and gives errors when one side isn’t a character vector. It no longer automatically applies glue interpolation to a non-glue input, if there is one. You’ll need to do that yourself (#286).
+
glue_collapse(character()) (and hence glue_sql_collapse(character())) now return "", so that they always return a single string (#88).
glue_collapse(character())
glue_sql_collapse(character())
""