This file contains hidden or 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) # needs dev version of ggplot2 for the colorbar | |
| if(0){ | |
| locs <- getCountriesFromGoogle(country="JP") | |
| weas <- llply(locs$name, function(l) { | |
| r <- NULL | |
| try(r <- getWeatherFromGoogle(l)) | |
| r | |
| }) |
This file contains hidden or 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(ggplot2) | |
| f <- function(y1, y2) { | |
| d <- seq.Date(as.Date(paste(y1, "-01-01", sep = "")), as.Date(paste(y2, "-12-31", sep = "")), "day") | |
| z <- data.frame( | |
| D = as.numeric(format(d, "%d")), | |
| W = format(d, "%w"), | |
| M = as.numeric(format(d, "%m")), | |
| Y = format(d, "%Y")) | |
This file contains hidden or 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(grid) | |
| library(animation) | |
| saveGIF({ | |
| ani.options(interval = 0.1, nmax = 200) | |
| for (x in seq(0, 1, length = 200)) { | |
| grid.newpage() | |
| grid.rect(gp = gpar(fill = "grey", col = NA)) | |
| grid.rect(seq(0, 1, 1/50), 1/4, 1/50/2, 1/2, gp = gpar(fill = "grey10", col = NA)) | |
| grid.rect(x, c(0.15, 0.3, 0.7, 0.85), 1/50, 0.1, gp = gpar(fill = c("black", "white"), col = NA)) |
This file contains hidden or 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(animation) | |
| ani.options(outdir = getwd()) | |
| saveGIF({ | |
| ani.options(interval = 1) | |
| grid.newpage() | |
| rs <- expand.grid(x = seq(0, 1, 1/10), y = seq(0, 1, 1/10)) | |
| grid.rect(rs$x, rs$y, 1/10/2, 1/10/2, gp = gpar(fill = "black", col = NA)) | |
| grid.rect(rs$x + 1/10/4, rs$y + 1/10/2, 1/10/2, 1/10/2, gp = gpar(fill = "black", col = NA)) | |
| ls <- expand.grid(x = 0:1, y = seq(0, 1, 1/20) - 1/20/2) | |
| grid.polyline(ls$x, ls$y, id = gl(nrow(ls)/2, 2), gp = gpar(col = "grey50", lwd = 1)) |
This file contains hidden or 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
| \documentclass{beamer} | |
| \usepackage{fontspec} | |
| \setsansfont{Hiragino Kaku Gothic Pro W3} | |
| \setmonofont{Monaco} | |
| \XeTeXlinebreaklocale "ja" | |
| \XeTeXlinebreakskip=0pt plus 1pt | |
| \XeTeXlinebreakpenalty=0 | |
| \def\<{\@ifstar{\zx@hwback\nobreak}{\zx@hwback\relax}} | |
| \def\zx@hwback#1{\leavevmode#1\hskip-.5em\relax}%% LyX 2.1.0svn created this file. For more info, see http://www.lyx.org/. |
This file contains hidden or 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
| `|` <- function(a, b) { | |
| env <- parent.frame() | |
| ret <- eval(a, env) | |
| bb <- llply(substitute(b), function(x) if(x==alist(,)[[1]]) ret else x) | |
| if (length(bb) == 1) bb[[2]] <- ret | |
| invisible(eval(as.call(bb), env)) | |
| } | |
| s <- "a" | |
| (1 + 1) | paste(,2, sep=s) | sub("a", "b", ) | print |
This file contains hidden or 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
| stop("intentional foul") |
This file contains hidden or 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
| method.name <- "test" | |
| eval(parse(text=sprintf('setGeneric("%s", function(object) standardGeneric("%s"))', method.name, method.name))) |
This file contains hidden or 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
| #' fujipie | |
| #' | |
| #' 例のフジテレビのパイチャート関数 | |
| #' | |
| #' @param d numeric vector データベクトル | |
| #' @param x,y numeric 歪み | |
| #' @param r numeric (> 0) 良心(大きいほど良心的) | |
| #' @param a numeric [0-1]. 良心(小さいほど良心的) | |
| fujipie <- function(d, x, y, r, a) { | |
| par(mar=c(0,0,0,0)) |
This file contains hidden or 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
| curve(sqrt(abs(1-x^2)), -1, -0.4, asp = 1, type = "l", xlim = c(-1.2, 1.2), ylim = c(-1.2, 1.2)) | |
| curve(sqrt(abs(1-x^2)), 0.4, 1, add = T, type = "l") | |
| curve(-sqrt(abs(1-x^2)), -1, -0.2, add = T, type = "l") | |
| curve(-sqrt(abs(1-x^2)), 0.2, 1, add = T, type = "l") | |
| curve(0.3 + 1.35 * sqrt(abs(0.6^2-x^2)), -0.6, 0.6, add = T, type = "l") | |
| curve(0.3 + 1.35 * -sqrt(abs(0.6^2-x^2)), -0.6, 0.6, add = T, type = "l") | |
| curve(-0.1+0*x, -0.5, -0.4, add = T, type = "l") | |
| curve(-0.1+0*x, -0.2, 0.5, add = T, type = "l") |