Git Product home page Git Product logo

fastpermute's Introduction

License: AGPL v3

fastpeRmute

Fast Combinations and Permutations in R.

The fastpeRmute package offers efficient functions for computing combinations and permutations with and without repetition in R. The underlying implementation leverages C++ for optimal performance, making it potentially faster than both base R and other packages like gtools.

Installation

To install the latest development version from GitHub:

devtools::install_github("gi0na/fastpeRmute")

Usage

Combinations

Without Repetition

library(fastpeRmute)
combinations(n = 10, r = 4)

With Repetition

combinations(n = 10, r = 4, repeats.allowed = TRUE)

Permutations

Without Repetition

permutations(n = 4, r = 2)

With Repetition

permutations(n = 4, r = 2, repeats.allowed = TRUE)

Using Vectors and Lists

You can also generate combinations or permutations from specific vectors:

Combinations from a Vector

v = letters
combinations(v=v, r = 3)

Permutations from a Vector

v = letters[1:4]
permutations(v=v, r = 2)

Combinations from a List

v <- mapply(v1 = letters[1:4], v2 = sample(LETTERS)[1:4], FUN = function(v1, v2) c(v1, v2), SIMPLIFY = FALSE)
combinations(v=v, r = 3, out_format = 'tibble')

Permutations from a List

v <- mapply(v1 = letters[1:4], v2 = sample(LETTERS)[1:4], FUN = function(v1, v2) c(v1, v2), SIMPLIFY = FALSE)
permutations(v=v, r = 2, out_format = 'tibble')

Contributing

Feedback, contributions, and issues are welcome on the GitHub repository.

fastpermute's People

Contributors

gi0na avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.