{"id":16572316,"url":"https://github.com/jonocarroll/formulize","last_synced_at":"2026-04-21T04:31:07.863Z","repository":{"id":71014034,"uuid":"123867561","full_name":"jonocarroll/formulize","owner":"jonocarroll","description":"generate formula and recipe wrappers for modelling functions","archived":false,"fork":false,"pushed_at":"2018-01-27T20:59:02.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-09T12:55:05.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://alexpghayes.github.io/formulize/","language":"R","has_issues":false,"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/jonocarroll.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}},"created_at":"2018-03-05T05:07:42.000Z","updated_at":"2022-02-10T22:14:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"d84fb585-ae5c-45a3-b31d-8b4deeecc3a9","html_url":"https://github.com/jonocarroll/formulize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jonocarroll/formulize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fformulize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fformulize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fformulize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fformulize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonocarroll","download_url":"https://codeload.github.com/jonocarroll/formulize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonocarroll%2Fformulize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32076839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T02:38:07.213Z","status":"ssl_error","status_checked_at":"2026-04-21T02:38:06.559Z","response_time":128,"last_error":"SSL_read: 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":[],"created_at":"2024-10-11T21:27:08.617Z","updated_at":"2026-04-21T04:31:07.845Z","avatar_url":"https://github.com/jonocarroll.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 setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# formulize\n\n[![Travis build status](https://travis-ci.org/alexpghayes/formulize.svg?branch=master)](https://travis-ci.org/alexpghayes/formulize)\n[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/alexpghayes/formulize?branch=master\u0026svg=true)](https://ci.appveyor.com/project/alexpghayes/formulize)\n[![Coverage status](https://codecov.io/gh/alexpghayes/formulize/branch/master/graph/badge.svg)](https://codecov.io/github/alexpghayes/formulize?branch=master)\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/formulize)](https://cran.rstudio.com/web/packages/formulize/index.html)\n![Downloads](http://cranlogs.r-pkg.org/badges/formulize)\n\nIf you:\n\n- like using formulas, recipes and data frames to specify design matrices\n- develop nervous ticks when you come across modelling packages that only offer matrix/vector interfaces\n- don't have the time or motivation to write a formula wrapper around these interfaces\n- like untested and hacky software written by amateurs\n\nthen `formulize` may be for you. Formulize is very new, but you can install it from CRAN if you have R 3.4+ with:\n\n```{r, eval = FALSE}\ninstall.packages(\"formulize\")\n```\n\nYou can get the development version (recommended) with:\n\n```{r, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"alexpghayes/formulize\")\n```\n\n## Adding a formula or recipe interface\n\nSuppose you want to add a formula interface to an existing modelling function, say `cv.glmnet`. Then you could do the following\n\n```{r, message = FALSE, warning = FALSE}\nlibrary(recipes)\nlibrary(glmnet)\nlibrary(formulize)\n\nglmnet_cv \u003c- formulize(cv.glmnet)\n\nglmnet_model \u003c- glmnet_cv(mpg ~ drat + hp - 1, mtcars)\npredict(glmnet_model, head(mtcars))\n```\n\nSimilarly `glmnet_cv` works with recipe objects like so\n\n```{r}\nrec \u003c- recipe(mpg ~ drat + hp, data = mtcars)\n\nglmnet_model2 \u003c- glmnet_cv(rec, mtcars)\npredict(glmnet_model2, head(mtcars))\n```\n\nYou may also be interested in the more ~~dangerous~~ exciting version `genericize`, which you should call for its side effects.\n\n```{r}\ngenericize(cv.glmnet)\n\nform \u003c- mpg ~ drat + hp - 1\nX \u003c- model.matrix(form, mtcars)\ny \u003c- mtcars$mpg\n\nset.seed(27)\nmat_model \u003c- cv.glmnet(X, y, intercept = TRUE)\n\nset.seed(27)\nfrm_model \u003c- cv.glmnet(form, mtcars, intercept = TRUE)\n\nset.seed(27)\nrec_model \u003c- cv.glmnet(rec, mtcars, intercept = TRUE)\n\npredict(mat_model, head(X))\npredict(frm_model, head(mtcars))\npredict(rec_model, head(mtcars))\n```\n\nThis creates a new S3 generic `cv.glmnet`, sets the provided function as the default method (`cv.glmnet.default`), and adds methods `cv.glmnet.formula` and `cv.glmnet.recipe` using `formulize`. \n\nThis will mask `cv.glmnet` and features no safety checks because safety isn't fun.\n\n## Caveats\n\n- `formulize` doesn't do anything special with intercepts. This means that you need to careful with functions that require you to specify intercepts in non-standard ways, such as `cv.glmnet` above. \n- If the original modelling function doesn't return a list, `formulize` will probably break.\n- If you're just looking for a formula interface to `glmnet`, take a look at [glmnetUtils](https://github.com/Hong-Revo/glmnetUtils).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fformulize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonocarroll%2Fformulize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonocarroll%2Fformulize/lists"}