{"id":13712268,"url":"https://github.com/grantmcdermott/parttree","last_synced_at":"2025-04-05T21:08:15.911Z","repository":{"id":48615510,"uuid":"249898065","full_name":"grantmcdermott/parttree","owner":"grantmcdermott","description":"R package for plotting simple decision tree partitions","archived":false,"fork":false,"pushed_at":"2025-01-16T19:17:36.000Z","size":11166,"stargazers_count":98,"open_issues_count":0,"forks_count":23,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-29T20:06:12.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://grantmcdermott.com/parttree","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/grantmcdermott.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":"2020-03-25T05:52:20.000Z","updated_at":"2025-02-05T20:27:38.000Z","dependencies_parsed_at":"2024-11-13T22:31:35.925Z","dependency_job_id":"17a6492a-3d28-4cb7-90b2-a3e21da68385","html_url":"https://github.com/grantmcdermott/parttree","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantmcdermott%2Fparttree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantmcdermott%2Fparttree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantmcdermott%2Fparttree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grantmcdermott%2Fparttree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grantmcdermott","download_url":"https://codeload.github.com/grantmcdermott/parttree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399877,"owners_count":20932876,"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","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-08-02T23:01:16.570Z","updated_at":"2025-04-05T21:08:15.895Z","avatar_url":"https://github.com/grantmcdermott.png","language":"R","funding_links":[],"categories":["Plot layers","R"],"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)\n```\n\n# parttree \u003ca href='https://grantmcdermott.com/parttree/'\u003e\u003cimg src='man/figures/hex.png' align=\"right\" width=\"120\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/parttree)](https://CRAN.R-project.org/package=parttree)\n[![R-universe status badge](https://grantmcdermott.r-universe.dev/badges/parttree)](https://grantmcdermott.r-universe.dev)\n[![R-CMD-check](https://github.com/grantmcdermott/parttree/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/grantmcdermott/parttree/actions/workflows/R-CMD-check.yaml)\n[![Docs](https://img.shields.io/badge/docs-homepage-blue.svg)](https://grantmcdermott.com/parttree/index.html)\n\u003c!-- badges: end --\u003e\n\nVisualize simple 2-D decision tree partitions in R. The **parttree**\npackage provides visualization methods for both base R graphics (via \n[**tinyplot**](https://grantmcdermott.com/tinyplot/)) and\n[**ggplot2**](https://ggplot2.tidyverse.org/).\n\n## Installation\n\nThe stable version of **parttree** is available on CRAN.\n\n``` r\ninstall.packages(\"parttree\")\n```\n\nOr, you can grab the latest development version from\n[R-universe](https://grantmcdermott.r-universe.dev/parttree).\n\n``` r\ninstall.packages(\"parttree\", repos = \"https://grantmcdermott.r-universe.dev\")\n```\n## Quickstart\n\nThe **parttree** [homepage](https://grantmcdermott.com/parttree/index.html)\nincludes an introductory vignette and detailed documentation. But here's a \nquickstart example using the\n[\"kyphosis\"](https://search.r-project.org/CRAN/refmans/rpart/html/kyphosis.html)\ndataset that comes bundled with the **rpart** package. In this case, we are\ninterested in predicting kyphosis recovery after spinal surgery, as a function \nof 1) the number of topmost vertebra that were operated, and 2) patient age.\n\nThe key function is `parttree()`, which comes with its own plotting method.\n\n```{r quickstart}\nlibrary(rpart)     # For the dataset and fitting decisions trees\nlibrary(parttree)  # This package\n\nfit = rpart(Kyphosis ~ Start + Age, data = kyphosis)\n\n# Grab the partitions and plot\nfit_pt = parttree(fit)\nplot(fit_pt)\n```\n\nCustomize your plots by passing additional arguments:\n\n```{r quickstart2}\nplot(\n   fit_pt,\n   border  = NA,                                     # no partition borders\n   pch     = 19,                                     # filled points\n   alpha   = 0.6,                                    # point transparency\n   grid    = TRUE,                                   # background grid\n   palette = \"classic\",                              # new colour palette\n   xlab    = \"Topmost vertebra operated on\",         # custom x title\n   ylab    = \"Patient age (months)\",                 # custom y title\n   main    = \"Tree predictions: Kyphosis recurrence\" # custom title\n)\n```\n\n### ggplot2\n\nFor **ggplot2** users, we offer an equivalent workflow via the `geom_partree()`\nvisualization layer.\n\n```{r quickstart_gg}\nlibrary(ggplot2) ## Should be loaded separately\n\nggplot(kyphosis, aes(x = Start, y = Age)) +\n  geom_parttree(data = fit, alpha = 0.1, aes(fill = Kyphosis)) + # \u003c-- key layer\n  geom_point(aes(col = Kyphosis)) +\n  labs(\n    x = \"No. of topmost vertebra operated on\", y = \"Patient age (months)\",\n    caption = \"Note: Points denote observations. Shading denotes model predictions.\"\n    ) +\n  theme_minimal()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantmcdermott%2Fparttree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrantmcdermott%2Fparttree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrantmcdermott%2Fparttree/lists"}