This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source('r3js.r') | |
obj <- r3js_new() | |
N <- 250 | |
x <- rnorm(N, 0.5, 0.2) | |
y <- rnorm(N, 0.5, 0.2) | |
z <- rnorm(N, 0.5, 0.2) | |
obj <- r3js_add(obj, r3js_point(x, y, z)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("devtools", dep = TRUE) | |
library(devtools) | |
dev_mode() | |
install_github("r3js", "kohske") | |
library(r3js) | |
example(r3js_gen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d <- iconv(readLines("http://www.asahi-net.or.jp/~tk7m-ari/sazae_ichiran.html"), "sjis") | |
d <- strsplit(gsub("<BR>$", "", d[grepl("^第[0-9]+回", d)]), "\t") | |
d <- as.data.frame(do.call("rbind", d), stringsAsFactors = FALSE) | |
names(d) <- c("N", "D", "H") | |
d[d$N=="第7回", ]$D <- "91.12.01" | |
d <- transform(d, | |
N = gsub("[^0-9]", "", N), | |
D = as.Date(D, "%y.%m.%d"), | |
H = ifelse(grepl("グー", H), "グー", | |
ifelse(grepl("チョキ", H), "チョキ", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nested loop creation | |
s <- (Reduce(function(a, b) substitute(`for`(i, j:3, x), list(i = as.name(letters[b]), j = `if`(b == 1, 1, as.name(letters[b-1])), x = a)), 4:1, quote(print(c(a, b, c, d))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(Rの)プロミス問題 その2。 | |
http://qiita.com/items/660eac769fa1a82fbf42 の続き。 | |
## Promiseとは | |
非常にざっくり言うと、プロミスとは「レシピと調理場を指定されたおっさん」です。 | |
プロミスを作るということは、おっさんにレシピと調理場を教えといて、いつでも必要なときにご飯を出してもらえるように準備しといてもらいます。 | |
おっさんは、「メシっ」って言われてら、調理場に走って行って、レシピを見て、料理を作ってくれます。 | |
なお、おっさんは、料理は作ってくれるんですが、それを見せてくれるだけです。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(reshape2) | |
library(ggplot2) | |
set.seed(42) | |
v1 <- rnorm(20, 0, 20) | |
v2 <- v1 + 0.1 + rnorm(20, 0, 0.1) | |
df1 <- melt(data.frame(v1, v2)) | |
TT1 <- t.test(value ~ variable, data = df1, paired = TRUE) | |
v1 <- rnorm(20, 0, 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A C-program for MT19937, with initialization improved 2002/1/26. | |
Coded by Takuji Nishimura and Makoto Matsumoto. | |
Before using, initialize the state by using init_genrand(seed) | |
or init_by_array(init_key, key_length). | |
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, | |
All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r setup, echo = FALSE} | |
opts_knit$set(out.format = 'html') | |
opts_chunk$set(highlight = TRUE) | |
``` | |
# Slidify | |
超簡単スライド作成 | |
@kohske |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## レポート書きましょう。 | |
# ライブラリ読み込み | |
library(plyr) | |
library(ggplot2) | |
library(reshape2) | |
library(grid) | |
# データ読み込み | |
data(iris) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' # Rスクリプトからレポート生成 | |
#' # `spin`ning in knitr package | |
#' | |
#' ### @kohske | |
#' | |
#' Rスクリプトはこちら | |
#' https://gist.github.com/gists/2975392 | |
#' | |
#' --- | |
#' |