glue
Glue strings to data in R. Small, fast, dependency free interpreted string literals.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 42 committers (2.4%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.6%) to scientific vocabulary
Keywords
r
string-interpolation
strings
Keywords from Contributors
parsing
tidy-data
csv
fwf
documentation-tool
unit-testing
tidyverse
data-manipulation
grammar
setup
Last synced: 6 months ago
·
JSON representation
Repository
Glue strings to data in R. Small, fast, dependency free interpreted string literals.
Basic Info
- Host: GitHub
- Owner: tidyverse
- License: other
- Language: R
- Default Branch: main
- Homepage: https://glue.tidyverse.org
- Size: 13.3 MB
Statistics
- Stars: 739
- Watchers: 21
- Forks: 63
- Open Issues: 6
- Releases: 16
Topics
r
string-interpolation
strings
Created about 9 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
Contributing
License
Code of conduct
Support
README.Rmd
---
output: github_document
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
library(glue)
```
# glue
[](https://cran.r-project.org/package=glue)
[](https://github.com/tidyverse/glue/actions/workflows/R-CMD-check.yaml)
[](https://github.com/tidyverse/glue/actions/workflows/test-coverage.yaml)
glue offers interpreted string literals that are small, fast, and dependency-free.
glue does this by embedding R expressions in curly braces, which are then evaluated and inserted into the string.
## Installation
::: .pkgdown-release
```{r, eval = FALSE}
# Install released version from CRAN
install.packages("glue")
```
:::
::: .pkgdown-devel
```{r, eval = FALSE}
# Install development version from GitHub
pak::pak("tidyverse/glue")
```
:::
## Usage
`glue()` makes it easy to interpolate data into strings:
```{r}
library(glue)
name <- "Fred"
glue("My name is {name}.")
```
`stringr::str_glue()` is an alias for `glue::glue()`.
So if you've already attached stringr (or perhaps the whole tidyverse), you can use `str_glue()` to access all of the functionality of `glue()`:
```{r eval = FALSE}
library(stringr) # or library(tidyverse)
name <- "Wilma"
str_glue("My name is {name}.")
#> My name is Wilma.
```
You're not limited to using a bare symbol inside `{}`; it can be any little bit of R code:
```{r}
name <- "Pebbles"
glue("Here is my name in uppercase and doubled: {strrep(toupper(name), 2)}.")
```
### Data can come from various sources
glue can interpolate values from the local environment or from data passed in `name = value` form:
```{r}
x <- "the local environment"
glue(
"`glue()` can access values from {x} or from {y}. {z}",
y = "named arguments",
z = "Woo!"
)
```
If the relevant data lives in a data frame (or list or environment), use `glue_data()` instead:
```{r}
mini_mtcars <- head(cbind(model = rownames(mtcars), mtcars))
glue_data(mini_mtcars, "{model} has {hp} hp.")
```
`glue_data()` is very natural to use with the pipe:
```{r}
mini_mtcars |>
glue_data("{model} gets {mpg} miles per gallon.")
```
These `glue_data()` examples also demonstrate that `glue()` is vectorized over the data.
### What you see is awfully close to what you get
`glue()` lets you write code that makes it easy to predict what the final string will look like.
There is considerably less syntactical noise and mystery compared to `paste()` and `sprintf()`.
Empty first and last lines are automatically trimmed, as is leading whitespace that is common across all lines.
You don't have to choose between indenting your code properly and getting the output you actually want.
Consider what happens when `glue()` is used inside the body of a function:
```{r}
foo <- function() {
glue("
A formatted string
Can have multiple lines
with additional indentation preserved")
}
foo()
```
The leading whitespace that is common to all 3 lines is absent from the result.
## Learning more
glue is a relatively small and focused package, but there's more to it than the basic usage of `glue()` and `glue_data()` shown here.
More recommended functions and resources:
* The "Get started" article (`vignette("glue")`) demonstrates more interesting features of `glue()` and `glue_data()`.
* `glue_sql()` and `glue_data_sql()` are specialized functions for producing SQL statements.
* glue provides a couple of custom knitr engines that allow you to use glue syntax in chunks; learn more in `vignette("engines", package = "glue")`.
## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](https://glue.tidyverse.org/CODE_OF_CONDUCT.html).
By participating in this project, you agree to abide by its terms.
Owner
- Name: tidyverse
- Login: tidyverse
- Kind: organization
- Website: http://tidyverse.org
- Repositories: 43
- Profile: https://github.com/tidyverse
The tidyverse is a collection of R packages that share common principles and are designed to work together seamlessly
GitHub Events
Total
- Issues event: 5
- Watch event: 13
- Issue comment event: 12
- Push event: 4
- Pull request review event: 1
- Fork event: 1
Last Year
- Issues event: 5
- Watch event: 13
- Issue comment event: 12
- Push event: 4
- Pull request review event: 1
- Fork event: 1
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Jim Hester | j****r@g****m | 328 |
| Jenny Bryan | j****n@g****m | 92 |
| Hadley Wickham | h****m@g****m | 15 |
| Gábor Csárdi | c****r@g****m | 4 |
| Mara Averick | m****k@g****m | 4 |
| shrektan | s****n@1****m | 4 |
| Adam Stone | a****e@g****m | 4 |
| Michael Chirico | m****4@g****m | 3 |
| Daniel Possenriede | p****e@g****m | 3 |
| Eugene Ha | e****a@p****e | 3 |
| Lionel Henry | l****y@g****m | 3 |
| Maximilian Girlich | m****h@m****m | 3 |
| Kirill Müller | k****r | 3 |
| Salim B | s****m@p****e | 2 |
| Alan Dipert | a****n@d****g | 2 |
| Andrew Hill | m****9 | 1 |
| Bill Denney | b****y | 1 |
| Brennan Antone | 1****e | 1 |
| Carl Howe | c****l@r****m | 1 |
| David C Hall | d****l | 1 |
| DavisVaughan | d****s@r****m | 1 |
| Edward Visel | a****e@g****m | 1 |
| Evgeni Chasnovski | e****i@g****m | 1 |
| moody_mudskipper | a****i@g****m | 1 |
| landesbergn | n****g@g****m | 1 |
| eitsupi | 5****i | 1 |
| dmurdoch | m****n@g****m | 1 |
| baptiste | b****e | 1 |
| Will Beasley | w****y@h****m | 1 |
| Victor Ordu | v****u@o****m | 1 |
| and 12 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 93
- Total pull requests: 52
- Average time to close issues: 10 months
- Average time to close pull requests: 4 months
- Total issue authors: 56
- Total pull request authors: 20
- Average comments per issue: 2.25
- Average comments per pull request: 1.75
- Merged pull requests: 44
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 10
- Pull requests: 12
- Average time to close issues: 4 days
- Average time to close pull requests: 4 days
- Issue authors: 10
- Pull request authors: 6
- Average comments per issue: 3.4
- Average comments per pull request: 0.75
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- jennybc (12)
- hadley (8)
- pnacht (5)
- jimhester (5)
- MichaelChirico (3)
- krlmlr (3)
- gaborcsardi (3)
- DanChaltiel (2)
- DavisVaughan (2)
- mmuurr (2)
- gadenbuie (1)
- calderonsamuel (1)
- TimTaylor (1)
- edgararuiz (1)
- Leprechault (1)
Pull Request Authors
- hadley (18)
- jennybc (14)
- billdenney (4)
- gaborcsardi (4)
- MichaelChirico (3)
- dpprdan (3)
- lionel- (2)
- pnacht (2)
- jimhester (2)
- stephhazlitt (2)
- BrennanAntone (2)
- pritikadasgupta (1)
- eitsupi (1)
- awong234 (1)
- krlmlr (1)
Top Labels
Issue Labels
feature (13)
documentation (10)
bug (4)
SQL :oil_drum: (4)
upkeep (1)
tidy-dev-day :nerd_face: (1)
Pull Request Labels
tidy-dev-day :nerd_face: (2)
Packages
- Total packages: 3
-
Total downloads:
- cran 1,124,755 last-month
- Total docker downloads: 169,499,468
-
Total dependent packages: 937
(may contain duplicates) -
Total dependent repositories: 3,799
(may contain duplicates) - Total versions: 46
- Total maintainers: 1
cran.r-project.org: glue
Interpreted String Literals
- Homepage: https://glue.tidyverse.org/
- Documentation: http://cran.r-project.org/web/packages/glue/glue.pdf
- License: MIT + file LICENSE
-
Latest release: 1.8.0
published over 1 year ago
Rankings
Downloads: 0.1%
Dependent repos count: 0.1%
Dependent packages count: 0.1%
Stargazers count: 0.5%
Forks count: 1.1%
Average: 3.2%
Docker downloads count: 17.3%
Maintainers (1)
Last synced:
6 months ago
proxy.golang.org: github.com/tidyverse/glue
- Documentation: https://pkg.go.dev/github.com/tidyverse/glue#section-documentation
- License: other
-
Latest release: v1.8.0
published over 1 year ago
Rankings
Dependent packages count: 9.0%
Average: 9.6%
Dependent repos count: 10.2%
Last synced:
6 months ago
conda-forge.org: r-glue
- Homepage: https://github.com/tidyverse/glue
- License: MIT
-
Latest release: 1.6.2
published almost 4 years ago
Rankings
Dependent packages count: 0.5%
Dependent repos count: 3.5%
Average: 10.7%
Stargazers count: 15.7%
Forks count: 22.9%
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.4 depends
- methods * imports
- DBI * suggests
- R.utils * suggests
- RSQLite * suggests
- covr * suggests
- crayon * suggests
- dplyr * suggests
- forcats * suggests
- ggplot2 * suggests
- knitr * suggests
- magrittr * suggests
- microbenchmark * suggests
- rmarkdown * suggests
- rprintf * suggests
- stringr * suggests
- testthat >= 3.0.0 suggests
- vctrs >= 0.3.0 suggests
- waldo >= 0.3.0 suggests
- withr * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml
actions
- JamesIves/github-pages-deploy-action 4.1.4 composite
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v2 composite
- r-lib/actions/pr-push v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite