Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gerrymanoim/humanize
R humanize functions
https://github.com/gerrymanoim/humanize
date human human-readable number r time
Last synced: about 1 month ago
JSON representation
R humanize functions
- Host: GitHub
- URL: https://github.com/gerrymanoim/humanize
- Owner: gerrymanoim
- License: other
- Created: 2018-03-08T01:49:26.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-04T01:32:54.000Z (over 6 years ago)
- Last Synced: 2024-09-23T03:19:31.149Z (3 months ago)
- Topics: date, human, human-readable, number, r, time
- Language: R
- Size: 78.1 KB
- Stars: 13
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```# humanize
[![Travis-CI Build Status](https://travis-ci.org/newtux/humanize.svg?branch=master)](https://travis-ci.org/newtux/humanize) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/humanize)](https://cran.r-project.org/package=humanize)
Humanize is an almost direct port of the python [humanize package](https://github.com/jmoiron/humanize).
The goal of humanize is to provide some utlities in order to turn values (so far times, file sizes, and numbers) into human readable forms.
## Installation
You can install the latest CRAN version with:
```{r cran-installation, eval=FALSE}
install.packages("humanize")
```You can install humanize from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("newtux/humanize")
```## Examples
### Times
Convert times:
```{r time_example}
library(humanize)natural_time(Sys.time())
natural_time(Sys.time() - 1)
natural_time(Sys.time() - 100)
natural_time(Sys.time() - 1000*10)
```Works across days:
```{r}
natural_time(Sys.time() - lubridate::ddays(1))
natural_time(Sys.time() - lubridate::ddays(70))
```And forward in time:
```{r}
natural_time(Sys.time() + lubridate::ddays(1))
```### File Sizes
Convert file sizes:
```{r size_example}
natural_size(300)
natural_size(3000)
natural_size(3000000)
natural_size(3000000000)
natural_size(3000000000000)
natural_size(10**26 * 30)
```### Numbers
Ordinals:
```{r}
count_as_ordinal(1)
count_as_ordinal(111)
```Comma Seperation:
```{r}
number_as_comma(1000)
number_as_comma(10000)
```Words:
```{r}
count_as_word(100)
count_as_word(1000000)
count_as_word(1200000000)
```AP Format:
```{r}
count_as_ap(3)
count_as_ap(20)
```## Todo
This is still a very early cut of the package.
- Better support in times? For diff time?
- Maybe add times relative to other times?
- Export helper functions used in tests?