Public
Edited
Nov 25, 2023
1 star
Insert cell
Insert cell
webR = {
// Set up webR
let { WebR } = await import('https://webr.r-wasm.org/v0.2.2/webr.mjs');
let webR = new WebR();
await webR.init();
return webR;
}
Insert cell
image = {
await webR.evalRVoid(`
# Create font dir and download font
dir.create("/home/web_user/fonts/")
download.file("https://raw.githubusercontent.com/WarBean/tps_stn_pytorch/master/Comic%20Sans%20MS.ttf", "/home/web_user/fonts/Comic Sans MS.ttf")

# Plot using Cairo PNG graphics device
png("plot.png", width = 600, height = 400, res = 100)
plot(rnorm(10000), family="Comic Sans MS")
dev.off()
`)

// Download image data
return await webR.FS.readFile("/home/web_user/plot.png")
}

Insert cell
{
const imgElem = new Image(600, 400);
imgElem.src = URL.createObjectURL(new Blob([image.buffer], { type: 'image/png' }))
return imgElem;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more