-
Originally asked (and answered) on twitter: How can we use tidy.js in rmarkdown? |
Beta Was this translation helpful? Give feedback.
Answered by
pbeshai
Feb 5, 2021
Replies: 2 comments
-
For anyone interested in using tidy.js with R Markdown (or Shiny apps), I've put together an R package that provides d3-array and the UMD version of tidy.js: https://github.com/gadenbuie/tidyjs-r |
Beta Was this translation helpful? Give feedback.
0 replies
-
switching to answer format As shown on twitter, this can be done this way or via @gadenbuie's new tidyjs-r package. ---
title: "Untitled"
output: html_document
---
<script src="https://d3js.org/d3-array.v2.min.js"></script>
<script src="https://www.unpkg.com/@tidyjs/tidy/dist/umd/tidy.min.js"></script>
```{js}
// everything is available under the Tidy namespace
const { tidy, mutate, arrange, desc } = Tidy;
const data = [
{ a: 1, b: 10 },
{ a: 3, b: 12 },
{ a: 2, b: 10 }
]
const results = tidy(
data,
mutate({ ab: d => d.a * d.b }),
arrange(desc('ab'))
)
``` |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
pbeshai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
switching to answer format
As shown on twitter, this can be done this way or via @gadenbuie's new tidyjs-r package.