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
--- | |
title: "RMarkdownでPythonInR" | |
author: '@kohske' | |
date: "2015年10月10日" | |
output: html_document | |
--- | |
参考 https://speakerdeck.com/yamano357/tokyor51-lt | |
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
--- | |
title: "RMarkdownでPythonInR" | |
author: '@kohske' | |
date: "2015年10月10日" | |
output: html_document | |
--- | |
参考 https://speakerdeck.com/yamano357/tokyor51-lt | |
フック |
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(gtable) | |
d=data.frame(g=c(1,1,1,2,2,3),x=c(1,2,3,1,2,3),y=1:6); | |
p = ggplot(d,aes(x,y))+geom_bar(stat="identity")+facet_wrap(~g) | |
gt= ggplot_gtable(ggplot_build(g)) | |
graphics.off() | |
for (p in c(4, 7, 10)) { | |
pdf(paste0("plot-", p, ".pdf")) | |
grid.draw(gt[,c(1:3, p, 12)]) |
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
# http://blog.goo.ne.jp/r-de-r/e/c9cc759642ea0c02560bd08c975fb156 | |
b = 0.111111 * 1:9 # b は 0.111111 ~ 0.999999 の 9 種類 | |
bz = b+0.000001 | |
b2 = 2 * b | |
bz2 = 2*bz | |
b.sq = b ^ 2 | |
bz.sq = bz ^ 2 | |
n = 10000 # 探索範囲上限 | |
ansa = c() |
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
> sessionInfo() | |
R version 3.1.1 (2014-07-10) | |
Platform: x86_64-apple-darwin13.1.0 (64-bit) | |
locale: | |
[1] ja_JP.UTF-8/ja_JP.UTF-8/ja_JP.UTF-8/C/ja_JP.UTF-8/ja_JP.UTF-8 | |
attached base packages: | |
[1] stats graphics grDevices utils datasets methods base |
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(rgl) | |
pie3d <- function(x, depth = 0.2, webgl = TRUE) { | |
x = cumsum(x)/sum(x) | |
ps = embed(c(0, 2*pi*x), 2) | |
for (i in 1:nrow(ps)) { | |
p = seq(ps[i, 2], ps[i, 1], by = 2*pi/360) | |
rgl.triangles(rep(c(t(cbind(embed(sin(p), 2), 0))), 2), |
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
Person <- R99Class("Person", | |
public : { | |
name = NA | |
hair = NA | |
# initialize | |
initialize = function(name, hair) { | |
if (!missing(name)) self$name <- name | |
if (!missing(hair)) self$hair <- hair |
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") | |
library(devtools) | |
dev_mode() | |
install_github("kohske/markdown@fix/encode") | |
install_github("kohske/slidify@fix/encode") | |
install_github("kohske/knitrBootstrap@fix/encode") | |
library(knitr) | |
knit2html("test-knit-CP932.Rmd", encoding="CP932") | |
knit2html("test-knit-UTF8.Rmd", encoding="UTF8") |
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
# ↓CP932 | |
> txt <- "あa" | |
> txt | |
[1] "あa" | |
> Encoding(txt) | |
[1] "unknown" | |
> charToRaw(txt) |
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
unlockBinding("to_deck", asNamespace("slidify")) | |
f <- function (doc) | |
{ | |
txt = str_split_fixed(read_file(doc), "\n---", 2) | |
meta = yaml.load(gsub("^---\n+", "", txt[1])) | |
meta <- lapply(meta, iconv, "utf8", "sjis") | |
cfile = ifelse(is.null(meta$config), "config.yml", meta$config) | |
deck = modifyList(get_config(cfile), c(meta, slides = txt[2])) | |
deck$standalone = ifelse(deck$mode == "standalone", TRUE, | |
FALSE) |