Run R code In the Browser

webr
without the need for an R server to execute the code
Author
Affiliation

Xinzhuo Huang

HKUST SOSC

Published

June 10, 2023

Modified

November 21, 2023

Sample

Code
library(ggplot2)

mtcars |>
    ggplot(aes(hp, mpg, colour = as.factor(am))) +
    geom_point() +
    geom_smooth(
        method = "lm", 
        linetype = "dashed",
        formula = y ~ x
    ) +
    theme_bw() +
    theme(
        panel.border = element_blank(),
        legend.position = "none"
    )+
    scale_color_manual(values = c("#0870A5", "#DB444B"))

Interactive R code editor

Let’s replicate the figure by running the code online. You can try different parameters yourself and run the code directly in the code area below.


Base R


  


Tidy R


  

  


Data Manipulation with dplyr


  

  

Citation

BibTeX citation:
@online{huang2023,
  author = {Huang, Xinzhuo},
  title = {Run {R} Code {In} the {Browser}},
  date = {2023-06-10},
  url = {https://xinzhuo.work/blog/run R code in the browser},
  langid = {en}
}
For attribution, please cite this work as:
Huang, Xinzhuo. 2023. β€œRun R Code In the Browser.” June 10, 2023. https://xinzhuo.work/blog/run R code in the browser.