Science Score: 33.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
-
○DOI references
-
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
1 of 2 committers (50.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.3%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Number rounding and formatting assistance
Basic Info
- Host: GitHub
- Owner: bcjaeger
- License: other
- Language: HTML
- Default Branch: master
- Homepage: https://bcjaeger.github.io/table.glue/
- Size: 1.7 MB
Statistics
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
- Releases: 2
Created almost 6 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
Contributing
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# table.glue
`r badger::badge_cran_checks("table.glue")`
`r badger::badge_cran_download("table.glue", "last-month", "green")`
[](https://zenodo.org/badge/latestdoi/291551786)
`r badger::badge_dependencies("table.glue")`
The goal of `table.glue` is to give you more control over the presentation of your data and also simplify the process of rounding, formatting, and presenting your data. The main idea is to create rounding specifications (starting with `round_spec()`) that can be plugged in, directly or through global options, to the `table_glue()` and `table_value()` functions.
## Installation
You can install the released version of table.glue from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("table.glue")
```
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("bcjaeger/table.glue")
```
## Example
Suppose we want to write a summary statement about the mean and standard deviation (SD) of a column in the `mtcars` data. We'll start by loading the `glue`, `table.glue`, and `magrittr` packages.
```{r}
library(glue) # for comparisons with table_glue
library(table.glue) # similar to glue but with built in rounding
library(magrittr) # make rounding specifications using %>%
```
### Use base R
The classic approach is to use base R functions `format`, `round`, and `paste`:
```{r}
col_name <- "mpg"
col_mean <- mean(mtcars[[col_name]])
col_sd <- sd(mtcars[[col_name]])
col_mean_pretty <- format(signif(col_mean, digits = 3), nsmall = 1)
col_sd_pretty <- format(signif(col_sd, digits = 3), nsmall = 1)
paste0("The mean (SD) of ", col_name, " is ",
col_mean_pretty, " (", col_sd_pretty, ") ")
```
This gets the job done! Still, the code may be a little hard to read for a user who isn't a grizzled `paste()` veteran. This is where the `glue` package is really useful.
### Use `glue()`
Instead of using `paste()`, `glue()` lets us write everything in one string, surrounding R object with curly brackets (i.e., "look at this {`R object`}" ) tells R that the `glue()` function should print the value of that R object rather than the raw string. For instance,
```{r}
glue("the mean (SD) of {col_name} is {col_mean_pretty} ({col_sd_pretty})")
```
This is certainly more readable and clean. The only thing `glue()` doesn't do is make the pretty versions of `col_mean` and `col_sd`. This is where `table.glue` comes in.
### Use `table_glue()`
The `table.glue` package lets you use `glue()` without having to make numbers pretty beforehand. For example, the code below uses `table_glue()`, one of the main functions in `table.glue`, to replicate the results we got from `glue()` but without using the pretty versions of `col_mean` and `col_sd`.
```{r example}
# notice that we are not using 'pretty' versions of col_mean and col_sd
table_glue("the mean (SD) of {col_name} is {col_mean} ({col_sd})")
```
### Summary
- `table_glue` applies a general rounding convention to all numeric data that are supplied in the input string.
- The goal is to combine the clean syntax of `glue()` with a convenient and generally acceptable rounding specification.
Hopefully, most of your rounding needs will be met without going any further than this. However, the rabbit hole does go deeper. Let's say you don't like the default rounding specification and you want to make your own. You can do that!
```{r}
rspec <- round_spec() %>% # make your own rounding specification
round_using_signif(digits = 2) # round to 2 significant digits
# table glue adopts all the rules given by your specification
table_glue("the mean (SD) of {col_name} is {col_mean} ({col_sd})",
rspec = rspec)
```
rounding specifications can also be passed into global options so that `table_glue()` and `table_value()` will use the specification automatically (see the [Setting a default rounding specification](https://bcjaeger.github.io/table.glue/articles/default_rounder.html) vignette)
Owner
- Name: Byron
- Login: bcjaeger
- Kind: user
- Location: Winston-Salem
- Company: Wake Forest School of Medicine
- Twitter: byronjaeger1
- Repositories: 11
- Profile: https://github.com/bcjaeger
Assistant professor of biostatistics and data science.
GitHub Events
Total
- Push event: 4
Last Year
- Push event: 4
Committers
Last synced: over 3 years ago
All Time
- Total Commits: 31
- Total Committers: 2
- Avg Commits per committer: 15.5
- Development Distribution Score (DDS): 0.065
Top Committers
| Name | Commits | |
|---|---|---|
| Byron | b****r@g****m | 29 |
| bjaeger | b****r@w****u | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: almost 2 years ago
All Time
- Total issues: 0
- Total pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Total issue authors: 0
- Total pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 1 day
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
- jennybc (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 269 last-month
- Total dependent packages: 0
- Total dependent repositories: 2
- Total versions: 5
- Total maintainers: 1
cran.r-project.org: table.glue
Make and Apply Customized Rounding Specifications for Tables
- Homepage: https://github.com/bcjaeger/table.glue
- Documentation: http://cran.r-project.org/web/packages/table.glue/table.glue.pdf
- License: MIT + file LICENSE
-
Latest release: 0.0.5
published over 1 year ago
Rankings
Dependent repos count: 19.3%
Stargazers count: 21.9%
Forks count: 27.8%
Dependent packages count: 28.7%
Average: 28.8%
Downloads: 46.5%
Maintainers (1)
Last synced:
11 months ago
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- glue * imports
- stringi * imports
- covr * suggests
- dplyr * suggests
- gt * suggests
- knitr * suggests
- magrittr * suggests
- rmarkdown * suggests
- testthat * suggests
- tibble * suggests
- tidyr * suggests
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v3 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/pr-commands.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/pr-fetch v1 composite
- r-lib/actions/pr-push v1 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite
.github/workflows/rhub.yaml
actions
- r-hub/actions/checkout v1 composite
- r-hub/actions/platform-info v1 composite
- r-hub/actions/run-check v1 composite
- r-hub/actions/setup v1 composite
- r-hub/actions/setup-deps v1 composite
- r-hub/actions/setup-r v1 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v3 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite