Python版東京都のCOVID-19のデータをとりあえずRで読み込み,2022年に限定してグラフを描く。
library(tidyverse) df = read_csv("https://okumuralab.org/~okumura/python/data/COVID-tokyo.csv") df1 = subset(df, date >= "2022-01-01") plot(df1$date, df1$confirmed, type="h", lwd=5, col="orange", lend=1)
データを周期7の時系列クラスに変換し,stl(Seasonal Decomposition of Time Series by Loess)で seasonal + trend + remainder に分解し,trend を折れ線グラフで描く:
x = ts(df1$confirmed, frequency=7) t = df1$date # svg("COVID-tokyo-stl.svg", width=7, height=5) # par(mgp=c(2, 0.8, 0)) plot(t, x, type="h", lwd=5, col="orange", lend=1, xlab="date", ylab="confirmed") points(t, exp(stl(log(x), "periodic")$time.series[,2]), type="l", lwd=2) # dev.off()
Last modified: