{"id":14067637,"url":"https://github.com/christophergandrud/mcreplicate","last_synced_at":"2026-02-21T06:44:38.022Z","repository":{"id":50793857,"uuid":"349321429","full_name":"christophergandrud/mcreplicate","owner":"christophergandrud","description":"Multi-core replicate for RStats","archived":false,"fork":false,"pushed_at":"2021-06-30T18:59:46.000Z","size":55,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-12-04T08:36:15.836Z","etag":null,"topics":["parallel-computing","rstats","rstats-package","simulation"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christophergandrud.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-19T06:19:26.000Z","updated_at":"2021-06-30T18:59:49.000Z","dependencies_parsed_at":"2022-08-30T08:31:04.342Z","dependency_job_id":null,"html_url":"https://github.com/christophergandrud/mcreplicate","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/christophergandrud/mcreplicate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophergandrud%2Fmcreplicate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophergandrud%2Fmcreplicate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophergandrud%2Fmcreplicate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophergandrud%2Fmcreplicate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christophergandrud","download_url":"https://codeload.github.com/christophergandrud/mcreplicate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophergandrud%2Fmcreplicate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267798625,"owners_count":24145727,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parallel-computing","rstats","rstats-package","simulation"],"created_at":"2024-08-13T07:05:42.121Z","updated_at":"2025-07-30T02:30:59.027Z","avatar_url":"https://github.com/christophergandrud.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput:\n  github_document:\n    html_preview: false\n---\n\n# mcreplicate: Multi-Core Replications\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/christophergandrud/mcreplicate/workflows/R-CMD-check/badge.svg)](https://github.com/christophergandrud/mcreplicate/actions)\n[![Codecov test coverage](https://codecov.io/gh/christophergandrud/mcreplicate/branch/main/graph/badge.svg)](https://codecov.io/gh/christophergandrud/mcreplicate?branch=main)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n\u003c!-- badges: end --\u003e\n\n**mcreplicate** adds multi-core functionality to R's `replicate` function. It allows easy parallelization on all platforms, including on Windows.\n\n\n## Installation\n\nInstall the package from GitHub:\n\n```r\nif (!require(remotes)) install.packages(\"remotes\")\nremotes::install_github(\"christophergandrud/mcreplicate\")\n```\n\n## Use\n\n`mc_replicate()` works just like `replicate()`, but distributes the replications on multiple cores\n\n```{r}\nlibrary(mcreplicate)\n\n# Function to replicate\none_sim \u003c- function(n = 100, control_prob = 0.1, rel_effect = 0.01) {\n  treat_prob \u003c- control_prob + (control_prob * rel_effect)\n    \n  cy \u003c- rbinom(n = n, size = 1, prob = control_prob)\n  ty \u003c- rbinom(n = n, size = 1, prob = treat_prob)\n  \n  mean(ty) - mean(cy)\n}\n\nmc_replicate(10, one_sim())\n```\n\n### Windows users\n\nOn Windows, **mcreplicate** relies on a parallel socket cluster backend. This requires the user to explicitly specify which packages and variables should be used to populate the workers' environments. By default, **mcreplicate** attaches all currently loaded packages and all variables from the current environment which do not start with a \".\". This can be changed using the `packages`, `varlist` and `envir` optional arguments. You can learn more on the function's help file.\n \n#### Example\n\n```{r, eval=FALSE}\nk = 2\n\n# The following works as intended since the variable \"k\" is exported by \n# default to each worker.\nmc_replicate(10, rnorm(k))\n\n# For a reduced overhead, you can specify to *only* export the variable \"k\" \n# from the current environment and to not load any particular package.\nmc_replicate(10, rnorm(k), packages = NULL, varlist = c(\"k\"), \n             envir = environment())\n```\n## References\n\nThis is inspired by the `mcreplicate` function from the [rethinking](https://github.com/rmcelreath/rethinking) package. We added Windows support and we provide a lightweight package.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophergandrud%2Fmcreplicate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristophergandrud%2Fmcreplicate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristophergandrud%2Fmcreplicate/lists"}