Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kos59125/naturalsort
Natural ordering in R
https://github.com/kos59125/naturalsort
Last synced: 8 days ago
JSON representation
Natural ordering in R
- Host: GitHub
- URL: https://github.com/kos59125/naturalsort
- Owner: kos59125
- License: other
- Archived: true
- Created: 2013-07-30T23:39:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-11-27T04:29:25.000Z (about 8 years ago)
- Last Synced: 2024-11-28T20:16:42.129Z (14 days ago)
- Language: R
- Size: 16.6 KB
- Stars: 8
- Watchers: 3
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - kos59125/naturalsort - Natural ordering in R (R)
README
naturalsort package
===================The package provides functions related to human natural ordering.
Installation
------------```r
install.packages("naturalsort")
```For `devtools` users, run:
```r
install_github("kos59125/naturalsort", subdir="naturalsort")
```Usage
-----```r
library(naturalsort)## Simple example.
text <- c("a1.png", "a2.png", "a10.png")
print(naturalsort(text))
print(sort(text)) # general sort## Reordering factors in natural order.
## After read.table with stringsAsFactors=TRUE, levels of column of factor is sorted in character order.
## If you prefer natural ordered factor, call read.table with stringsAsFactors=FALSE and creates factor column manually.
data <- read.table(file, header=TRUE, stringsAsFactors=FALSE)
data$SomeFactor <- factor(data$SomeFactor, levels=naturalsort(unique(data$SomeFactor)))
```