= {
data const co2data = await FileAttachment("co2_mm.csv")
.csv({ typed: true });
return co2data.map(d => {
"decimal date"] = Number(d["decimal date"]);
d[.average = Number(d.average);
dreturn d;
;
})
}.plot({
Plotmarks: [
.line(data,
Plotx: "decimal date", y: "average"},
{ stroke: "black" }
{
)
] })
NOAA CO2
Read and plot a CSV of NOAA’s Monthly CO2 concentration data from Mauna Loa:
Read the same data into R, do some grouping and summarization, then make it available using ojs_define
:
library(readr)
library(dplyr)
= read_csv("co2_mm.csv") %>%
co2 group_by(year) %>%
summarize(max = max(average))
ojs_define(co2data = co2)
Now plot the summarized data:
.plot({
Plotmarks: [
.line(transpose(co2data),
Plotx: "year", y: "max"},
{stroke: "black" }
{
)
]} )