WebTobinQ > Example

「WebTobinQ/Example」の編集履歴(バックアップ)一覧に戻る
WebTobinQ/Example」を以下のとおり復元します。
[[WebTobinQ]], [[WebTobinQ/Example/Chart]]

このページは実際に動いたコードを蓄積しています。

実際のサイト、http://webtobinq.appspot.com/ に行って、以下のコードをコピペしてみてEval Allしたり、一行ずつ末尾でEnterしたりしてみて下さい。

*** vectorかけるスカラー
 3*c(1, 2, 3)

*** ただのplot
 x <- 1:10
 y <- 1:10
 plot(x, y)

*** plot、lines、vector計算

year <- c(1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000)
gdp <- c(312712.7, 321490.5, 331710.7, 339823.8, 353436.2, 368184.1, 379895.7, 399442.3, 424657.3, 445468.8, 469780.5, 481660.7, 483375.6, 485498.4, 490730.7, 502794.3, 520053.8, 521315.1, 518380.7, 525695.8, 530312.8)
cons <- c(174382.7, 177074.9, 184799.3, 189292.0, 194237.4, 201627.8, 209050.0, 217356.6, 229129.5, 238784.9, 248840.1, 256905.6, 261560.2, 266385.2, 272342.2, 277906.5, 284766.8, 281393.7, 285094.0, 289454.2, 288981.1)
growth.gdp<-(gdp[2:21]-gdp[1:20])/gdp[2:21]*100
growth.cons<-(cons[2:21]-cons[1:20])/cons[2:21]*100
plot(year[2:21],growth.gdp)
lines(year[2:21],growth.cons)

*** mean, sqrt, var, <=, >

year <- c(1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000)
gdp <- c(312712.7, 321490.5, 331710.7, 339823.8, 353436.2, 368184.1, 379895.7, 399442.3, 424657.3, 445468.8, 469780.5, 481660.7, 483375.6, 485498.4, 490730.7, 502794.3, 520053.8, 521315.1, 518380.7, 525695.8, 530312.8)
growth.gdp<-((gdp[2:21]-gdp[1:20])/gdp[2:21])*100

ysub<-seq(1981,2000)
mean(growth.gdp[ysub<=1989])
sqrt(var(growth.gdp[ysub<=1989]))
mean(growth.gdp[ysub>1989])

**** 1980年代とそれ以降のgdp成長率の平均値を見る
 df <- read.server("http://webtobins.appspot.com/t/", "実質GDP", c("Fiscal Year", "GDP(expenditure approach)", "PrivateConsumption"), num=30)
 gdp <- df[["GDP(expenditure approach)"]]
 growth.gdp<-((gdp[2:30]-gdp[1:29])/gdp[2:30])*100
 ysub<-seq(1982,2010)
 mean(growth.gdp[ysub<=1989])
 mean(growth.gdp[ysub>1989])

復元してよろしいですか?

ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。