[Rd] Creating a text-based device/output format

Eric Berger er|cjberger @end|ng |rom gm@||@com
Tue Jun 25 14:42:15 CEST 2024


You might get more/additional feedback from the r-help list:

r-help using r-project.org


On Tue, Jun 25, 2024 at 2:18 PM David McArthur <
David.McArthur.2 using glasgow.ac.uk> wrote:

> Hi there, I hope I am sending this message to the right list.
>
> This is a “where should I start?” type question.
>
> I am a JavaScript developer, working on ideas for more accessible Maths
> and Stats coursework.  I have worked with RMarkdown and knitr extensively
> to create HTML coursework but I’m by no means an R developer!
>
> I recently came across a project called mermaid.js, which is designed for
> diagrams but has limited charting syntax:
> https://mermaid.js.org/syntax/xyChart.html
>
> This project aims to have plain text representation of graphics in
> markdown files, which when converted to HTML (either at compile time or at
> runtime), can turn these “mermaid” code blocks into a diagram/plot via a
> JavaScript parser and plotting library.
>
> This has inspired me to attempt to create a proof-of-concept for R along
> these lines.
>
> For example this R code:
>
> library(ggplot2)
> library(palmerpenguins)
>
> ggplot(data, aes(x=body_mass_g,fill = species)) +
>   geom _histogram()
>
> Could output something like:
>
> title "The body mass (g) of penguin species"
> x-axis "Body mass (g)" 3000 --> 5550
> y-axis "Count" 0 --> 2
> histogram
>   Adelie [3000, 3250, 3400]
>   ChinStrap [3250, 3600]
>   Gentoo [4300, 5050, 5200, 5300, 5450]
>
> How should I go about this in R?  I feel I should be aiming to create a
> new “device” or “output format”, but I haven’t found any examples on how to
> do this.
>
> One of my colleagues suggested I hook into ggplot_build, but then of
> course the project would be limited to ggplot plots.
>
> Any help greatly appreciated 😊
>
> Thanks,
>
> David McArthur
> School of Mathematics & Statistics
> University of Glasgow
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list