https://github.com/markvanderloo/gower
Gower's distance for R
https://github.com/markvanderloo/gower
Last synced: 8 months ago
JSON representation
Gower's distance for R
- Host: GitHub
- URL: https://github.com/markvanderloo/gower
- Owner: markvanderloo
- License: gpl-3.0
- Created: 2016-06-02T21:22:00.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-05-13T14:17:33.000Z (about 1 year ago)
- Last Synced: 2025-10-21T20:53:17.731Z (8 months ago)
- Language: C
- Homepage:
- Size: 107 KB
- Stars: 30
- Watchers: 4
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/markvanderloo/gower)
[](https://coveralls.io/r/markvanderloo/gower)
[](https://CRAN.R-project.org/package=gower)
[](https://CRAN.R-project.org/package=gower)
[](http://cran.r-project.org/package=gower)
### gower
Gower's distance for R. Based in C, using openMP for parallelization.
### Usage
```
library(gower)
reviris <- iris[rev(seq_len(nrow(iris))),,drop=FALSE]
# compute distances
d <- gower_dist(iris, reviris)
# data.frame with less records is recycled
d <- gower_dist(iris[1:3,,drop=FALSE], reviris)
# compute top-n matches
mat <- gower_topn(iris, reviris, n=5)
## mat$index : Array of indices (sorted from better to worse match)
## mat$distance: Array of distances (sorted from small to large)
```
More info in the [vignette](https://cran.r-project.org/web/packages/gower/vignettes/intro.pdf)
### Installation
#### From CRAN
```
install.packages("gower")
```
#### Beta versions
Made available through my drat repo.
First, install the [drat](https://cran.r-project.org/package=drat) package. Users of the OS who's name shall not be mentioned need to install [Rtools](https://cran.r-project.org/bin/windows/Rtools/) first.
```
if(!require(drat)) install.packages('drat')
drat::addRepo('markvanderloo')
install.packages('gower',type='source')
```
### Reference
Gower (1971) A general coefficient of similarity and some of its properties. _Biometrics_ **27** 857-874 [pdf](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.412.4155&rep=rep1&type=pdf)