経済関係の統計を気軽に扱えるサービスを目指して、WebTobinQという物を開発している。 基本的にはRのサブセット。[[WebTobinServer]] *** サイト http://webtobinq.appspot.com/ *** ソース http://code.google.com/p/webtobinq/ *** 独自関数 **** read.server(url, table, fields, range, num=10) url: [[WebTobinServer]]のURL (/t/も含む) table: tableの名前(文字列) fiels: (optional...だけど今はバグで必須) 取得したいcolumnの名前のvector。 range: (optional) list(fieldName, beg, end)というリストで、fieldNameのうちbeg以上end以下のrowを取ってくる。 fieldNameは文字列、 beg, endはnumeric(今の所) rum: 取得するrowのmax。サーバー負荷を考えてデフォルトは小さめにしてある。 最大で1000。 例 read.server("http://webtobins.appspot.com/t/", "実質GDP", c("Fiscal Year", "GDP(expenditure approach)", "PrivateConsumption"), num=30) ** 動いたコード *** 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]) *** read.server, data.frame関連 **** 消費とgdpをplotしてみる df <- read.server("http://webtobins.appspot.com/t/", "実質GDP", c("Fiscal Year", "GDP(expenditure approach)", "PrivateConsumption"), num=30) plot(df[["Fiscal Year"]],df[["GDP(expenditure approach)"]],ylim=c(100000,600000)) lines(df[["Fiscal Year"]],df[["PrivateConsumption"]]) **** 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]) ** 関連blog http://karino2.livejournal.com/tag/webtobinq [[R]]
下から選んでください: