{"id":13858370,"url":"https://github.com/timelyportfolio/d3r","last_synced_at":"2025-04-06T07:14:07.916Z","repository":{"id":56215925,"uuid":"66714348","full_name":"timelyportfolio/d3r","owner":"timelyportfolio","description":"d3.js helpers for R","archived":false,"fork":false,"pushed_at":"2023-10-07T17:09:14.000Z","size":2262,"stargazers_count":154,"open_issues_count":1,"forks_count":16,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-30T05:08:22.791Z","etag":null,"topics":["cran","d3","hierarchies","hierarchy","igraph","javascript","json","rstats"],"latest_commit_sha":null,"homepage":"https://timelyportfolio.github.io/d3r/","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/timelyportfolio.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"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}},"created_at":"2016-08-27T12:52:24.000Z","updated_at":"2025-03-22T11:20:17.000Z","dependencies_parsed_at":"2023-02-19T01:01:21.293Z","dependency_job_id":null,"html_url":"https://github.com/timelyportfolio/d3r","commit_stats":{"total_commits":168,"total_committers":4,"mean_commits":42.0,"dds":0.0535714285714286,"last_synced_commit":"7fa13cfe06015fc05c552a8c5c6ed9dd021693b8"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelyportfolio%2Fd3r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelyportfolio%2Fd3r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelyportfolio%2Fd3r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timelyportfolio%2Fd3r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timelyportfolio","download_url":"https://codeload.github.com/timelyportfolio/d3r/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247445680,"owners_count":20939961,"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":["cran","d3","hierarchies","hierarchy","igraph","javascript","json","rstats"],"created_at":"2024-08-05T03:02:06.244Z","updated_at":"2025-04-06T07:14:07.894Z","avatar_url":"https://github.com/timelyportfolio.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\nalways_allow_html: true\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, echo = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\"\n)\n```\n\n[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/d3r)](https://cran.r-project.org/package=d3r)\n[![R-CMD-check](https://github.com/timelyportfolio/d3r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/timelyportfolio/d3r/actions/workflows/R-CMD-check.yaml)\n\n### Installing d3r\n\n`d3r` is on CRAN, so install with `install.packages(\"d3r\")` or for the absolute latest use `devtools`.\n\n```\ndevtools::install_github(\"timelyportfolio/d3r\")\n```\n\n### d3 Dependency Functions\n\n`d3r` makes `d3.js` dependency injection in R easy with `d3_dep_v3()`, `d3_dep_v4()`, `d3_dep_v5()`, `d3_dep_v6()`, and the newest `d3_dep_v7()`.  These functions work well with `htmltools::tags`.\n\n```\nlibrary(htmltools)\nlibrary(d3r)\n\n# check web developer tools to see d3 is available\nbrowsable(\n  attachDependencies(\n    tagList(),\n    d3_dep_v7()\n  )\n)\n\n# or include directly in a taglist; I prefer this method.\nbrowsable(\n  tagList(\n    h1(\"I have d3 version \", span(id=\"version\")),\n    tags$script(\"d3.select('#version').text(d3.version)\"),\n    d3_dep_v7()\n  )\n)\n```\n\nAlso, I will commit to keeping `d3r` up-to-date with `d3.js`, so you'll no longer need multiple copies of `d3.js` for your `htmlwidgets`.  If you are a `htmlwidget` author, you will no longer need to worry every time `d3.js` gets a new release.  See `treebar` [lines](https://github.com/timelyportfolio/treebar/blob/master/R/treebar.R#L66-L74) for an example of using `d3r` with your `htmlwidget`.\n\n### d3 Hierarchy from data.frame\n\nBuilding `d3.js` hierarchies can be very difficult.  `d3r::d3_nest()` will convert `table` and `data.frame` to a nested `d3.js` hierarchy ready for work with [`d3-hierarchy`](https://github.com/d3/d3-hierarchy).\n\n```\nd3_nest(as.data.frame(Titanic))\n```\n\nAs another example, let's go from `treemap` to `d3.js`.\n\n```\nlibrary(treemap)\nlibrary(d3r)\n\nd3_nest(\n  treemap::random.hierarchical.data(),\n  value_cols = \"x\"\n)\n```\n\n### d3 Hierarchy from partykit / rpart\n\n`rpart` and similar objects in `R` are very difficult to convert but make perfect subjects for `d3` hierarchical layouts.  `d3_party` helps convert these objects for easy usage with `d3.js`.\n\n```\n#devtools::install_github(\"timelyportfolio/d3treeR\")\n\nlibrary(d3treeR)\nlibrary(d3r)\n\n# example from ?rpart\ndata(\"kyphosis\", package=\"rpart\")\nrp \u003c-  rpart::rpart(\n  Kyphosis ~ Age + Number + Start,\n  data = kyphosis\n)\n\n# get the json hierarchy\nd3_party(tree=rp)\n\n# interactive plot with d3treeR\nd3tree2(\n  d3_party(tree=rp),\n  celltext=\"description\",\n  valueField=\"n\"\n)\n```\n\n### d3 Network from igraph\n\n`igraph` to `d3.js` network of `nodes` and `links` is a very common conversion.  `d3r::d3_igraph` will do this for you.\n\n```\nlibrary(igraph)\nlibrary(d3r)\n\nd3_igraph(igraph::watts.strogatz.game(1, 50, 4, 0.05))\n```\n\n### Todo\n\nI have a whole lot of ideas.  Please let me know yours, and let's make this package great.\n\n### Code of Conduct\n\nPlease note that this project is released with a [Contributor Code of Conduct](https://github.com/timelyportfolio/d3r/blob/master/CONDUCT.md). By participating in this project you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimelyportfolio%2Fd3r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimelyportfolio%2Fd3r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimelyportfolio%2Fd3r/lists"}