{"id":32203682,"url":"https://github.com/tsostarics/contrastable","last_synced_at":"2026-02-20T16:02:04.590Z","repository":{"id":45201039,"uuid":"403337329","full_name":"tsostarics/contrastable","owner":"tsostarics","description":"Contrast Coding Utilities","archived":false,"fork":false,"pushed_at":"2025-11-25T03:19:43.000Z","size":2799,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-09T09:33:26.958Z","etag":null,"topics":["contrasts","modeling","rstats","statistics"],"latest_commit_sha":null,"homepage":"https://tsostarics.github.io/contrastable/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tsostarics.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-09-05T15:01:09.000Z","updated_at":"2025-11-25T03:15:23.000Z","dependencies_parsed_at":"2023-12-22T04:40:08.809Z","dependency_job_id":"6fb32fb8-91d5-4649-81fd-b065ddb567c1","html_url":"https://github.com/tsostarics/contrastable","commit_stats":{"total_commits":217,"total_committers":1,"mean_commits":217.0,"dds":0.0,"last_synced_commit":"64224b406a66f2be37c3d2aa000f1ac6754cd339"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/tsostarics/contrastable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsostarics%2Fcontrastable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsostarics%2Fcontrastable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsostarics%2Fcontrastable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsostarics%2Fcontrastable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tsostarics","download_url":"https://codeload.github.com/tsostarics/contrastable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tsostarics%2Fcontrastable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29656589,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T09:27:29.698Z","status":"ssl_error","status_checked_at":"2026-02-20T09:26:12.373Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["contrasts","modeling","rstats","statistics"],"created_at":"2025-10-22T04:45:09.142Z","updated_at":"2026-02-20T16:02:04.583Z","avatar_url":"https://github.com/tsostarics.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  message = FALSE,\n  warning = FALSE\n)\n```\n\n# contrastable\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/contrastable)](https://CRAN.R-project.org/package=contrastable)\n[![](https://img.shields.io/badge/doi-10.32614/CRAN.package.contrastable-blue.svg)](https://doi.org/10.32614/CRAN.package.contrastable)\n\n[![Codecov test coverage](https://codecov.io/gh/tsostarics/contrastable/branch/main/graph/badge.svg?token=PW2NOWO8NE)](https://app.codecov.io/gh/tsostarics/contrastable?branch=main)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![R-CMD-check](https://github.com/tsostarics/contrastable/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tsostarics/contrastable/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nThis package provides utilities to set different common contrast coding schemes\nfor use with regression models.\nPlease see [tsostarics.github.io/contrastable/](https://tsostarics.github.io/contrastable/) for the package website containing documentation, get started guide, and related vignettes.\n\n\n## Installation\n\nYou can install from CRAN with:\n\n```{r, eval = FALSE}\ninstall.packages(\"contrastable\")\n```\n\n\nYou can install the development version from [GitHub](https://github.com/) with:\n\n```r\n# install.packages(\"devtools\")\ndevtools::install_github(\"tsostarics/contrastable\", build_vignettes = TRUE)\n```\n\n## Citation\n\nTo cite `contrastable` in publications, please use\n\nSostarics, T. (2024). contrastable: Contrast Coding Utilities in R. R package version `r packageVersion(\"contrastable\")`. https://CRAN.R-project.org/package=contrastable. doi:10.32614/CRAN.package.contrastable\n\nA BibTeX entry for LaTeX users is\n\n```\n@Manual{contrastable,\n  author = {Thomas Sostarics},\n  title = {{contrastable}: Contrast Coding Utilities in {R}},\n  year = {2024},\n  note = {R package version `r packageVersion(\"contrastable\")`},\n  url = {https://CRAN.R-project.org/package=contrastable},\n  doi = {10.32614/CRAN.package.contrastable},\n}\n```\n\nSee the Citation Examples section in the contrasts vignette for suggestions\nand examples of how to cite this package in a paper.\n\n\n\n# Usage\n\nHere is a simple example showing how to set particular factors to a specific\ncontrast scheme. \n\n```{r}\nlibrary(contrastable)\nmy_data \u003c- mtcars\nmy_data$gear \u003c- ordered(my_data$gear) # Set as ordered factor in dataframe\n```\n\n\n`set_contrasts` can be used to set the contrasts onto the dataframe itself,\nwhich is needed when a modeling function lacks a `contrasts` argument.\n\n```{r, message = TRUE}\n# Specify the contrast schemes we want, factor conversion done automatically\n# Set reference level with + and intercept with *\nmy_data \u003c- set_contrasts(my_data, \n                         cyl ~ scaled_sum_code + 6,\n                         carb ~ helmert_code,\n                         vs ~ treatment_code + 1,\n                         print_contrasts = TRUE)\n```\n\n\nWe can use `glimpse_contrasts` to get information about\nthe factors and diagnostics about the scheme we have set.\n\n```{r, message = TRUE, warning=FALSE}\n# Create a reusable list to use with multiple functions\ncontrast_schemes \u003c- list(\n  cyl ~ scaled_sum_code + 6,\n  carb ~ helmert_code,\n  vs ~ treatment_code + 1\n)\n\n# Get information about our contrasts, even those we didn't explicitly set\n# (gear is ordered, and so uses contr.poly by default)\nglimpse_contrasts(my_data,\n                  contrast_schemes,\n                  add_namespace = TRUE,\n                  show_all_factors = TRUE) |\u003e\n  knitr::kable()\n```\n\n\n`enlist_contrasts` can be used to generate a named list of contrasts\nthat can be used in the `contrasts` argument of various modeling functions.\n\n```{r, eval = FALSE, echo = TRUE}\n# Get a list of the contrasts we've explicitly set\nenlist_contrasts(mtcars, contrast_schemes)\n```\n\n```{r, echo = FALSE}\nlapply(enlist_contrasts(mtcars, contrast_schemes), MASS::fractions)\n```\n\n\nYou can also set multiple contrasts at once using `{tidyselect}` functionality.\n\n```{r}\n# Create a new dataframe with a bunch of factors\nmy_data2 \u003c- \n  data.frame(a = gl(2,10),\n             b = gl(5,2, ordered = TRUE),\n             c = gl(5,2),\n             d = 1:10,\n             e = 11:20)\n\nenlist_contrasts(my_data2,\n                 where(is.ordered) ~ polynomial_code,\n                 where(is.unordered) ~ helmert_code,\n                 d + e ~ sum_code)\n```\n\nThe functions in this package aim to be helpful when potential mistakes are\nmade and transparent when things happen behind the scenes (e.g., automatic\nfactor coercion).\nYou can check out descriptions of various messages and warnings in the\n`warnings` vignette with `vignette('warnings', 'contrastable')`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsostarics%2Fcontrastable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftsostarics%2Fcontrastable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftsostarics%2Fcontrastable/lists"}