https://github.com/krlmlr/wrswor
A package with different implementations of weighted random sampling without replacement in R
https://github.com/krlmlr/wrswor
Last synced: about 1 month ago
JSON representation
A package with different implementations of weighted random sampling without replacement in R
- Host: GitHub
- URL: https://github.com/krlmlr/wrswor
- Owner: krlmlr
- Created: 2013-03-05T08:11:44.000Z (about 12 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T00:27:37.000Z (over 1 year ago)
- Last Synced: 2024-04-24T14:08:55.547Z (about 1 year ago)
- Language: TeX
- Homepage: https://krlmlr.github.io/wrswoR
- Size: 24 MB
- Stars: 17
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
pkgload::load_all()
```# wrswoR
[](https://www.tidyverse.org/lifecycle/#stable)
[](https://github.com/krlmlr/wrswoR/actions)
[](https://codecov.io/gh/krlmlr/wrswoR?branch=main)
[](https://CRAN.R-project.org/package=wrswoR)The goal of wrswoR is to provide faster implementations of weighted random sampling without replacement in R.
## Installation
You can install the released version of wrswoR from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("wrswoR")
```And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("krlmlr/wrswoR")
```
## ExampleThe functions in this package are a drop-in replacement to `sample.int(n, size, replace = FALSE, prob = prob)`.
With large `n`, `sample.int()` becomes too slow to be practical, unlike the functions in this package.```{r example}
library(wrswoR)
set.seed(20200726)sample_int_crank(20, 10, 1:20)
```