Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughjonesd/santoku
A versatile cutting tool for R
https://github.com/hughjonesd/santoku
Last synced: 14 days ago
JSON representation
A versatile cutting tool for R
- Host: GitHub
- URL: https://github.com/hughjonesd/santoku
- Owner: hughjonesd
- License: other
- Created: 2019-08-30T15:41:46.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T11:11:52.000Z (5 months ago)
- Last Synced: 2024-10-09T09:39:05.771Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://hughjonesd.github.io/santoku
- Size: 19.2 MB
- Stars: 136
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - hughjonesd/santoku - A versatile cutting tool for R (JavaScript)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)```
# santoku
[![CRAN status](https://www.r-pkg.org/badges/version/santoku)](https://CRAN.R-project.org/package=santoku)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![CRAN Downloads Per Month](http://cranlogs.r-pkg.org/badges/santoku)](https://CRAN.R-project.org/package=santoku)
[![R-universe](https://hughjonesd.r-universe.dev/badges/santoku)](https://hughjonesd.r-universe.dev/santoku)
[![R-CMD-check](https://github.com/hughjonesd/santoku/workflows/R-CMD-check/badge.svg)](https://github.com/hughjonesd/santoku/actions)
[![Codecov test coverage](https://codecov.io/gh/hughjonesd/santoku/branch/master/graph/badge.svg)](https://app.codecov.io/gh/hughjonesd/santoku?branch=master)santoku is a versatile cutting tool for R. It provides `chop()`, a replacement
for `base::cut()`.## Installation
Install from [r-universe](https://r-universe.dev):
``` r
install.packages("santoku", repos = c("https://hughjonesd.r-universe.dev",
"https://cloud.r-project.org"))
```Or from CRAN:
``` r
install.packages("santoku")
```Or get the development version from github:
``` r
# install.packages("remotes")
remotes::install_github("hughjonesd/santoku")
``````{r, child = 'advantages.Rmd'}
```## Examples
```{r}
library(santoku)
````chop` returns a factor:
```{r}
chop(1:5, c(2, 4))
```Include a number twice to match it exactly:
```{r}
chop(1:5, c(2, 2, 4))
```Use names in breaks for labels:
```{r}
chop(1:5, c(Low = 1, Mid = 2, High = 4))
```Or use `lbl_*` functions:
```{r}
chop(1:5, c(2, 4), labels = lbl_dash())
```Chop into fixed-width intervals:
```{r}
chop_width(runif(10), 0.1)
```Or into fixed-size groups:
```{r}
chop_n(1:10, 5)
```Chop dates by calendar month, then tabulate:
```{r}
library(lubridate)dates <- as.Date("2021-12-31") + 1:90
tab_width(dates, months(1), labels = lbl_discrete(fmt = "%d %b"))
```For more information, see the [vignette](https://hughjonesd.github.io/santoku/articles/santoku.html).