Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Tsukuba

on

  • 4,394 views

 

Statistics

Views

Total Views
4,394
Views on SlideShare
4,136
Embed Views
258

Actions

Likes
12
Downloads
58
Comments
1

4 Embeds 258

http://d.hatena.ne.jp 246
https://twitter.com 6
http://www.slideshare.net 5
http://paper.li 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Tsukuba Tsukuba Presentation Transcript

    • 3 ggplot2 id:syou6162 Sunday, November 22, 2009
    • • id:syou6162 • • (M1) • Sunday, November 22, 2009
    • • 7 NAIST => • 8 • Sunday, November 22, 2009
    • R !! • wiki ! • http://www.okada.jp.org/RWiki/?R %B7%C7%BC%A8%C8%C4#i3afa741 • Tsukuba.R Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • • • plot • Sunday, November 22, 2009
    • graphic • id:wakuteka(Tsukuba.R#1) • Happy Graphics! • id:syou6162(Tsukuba.R#2) • • id:mickey24(Tsukuba.R#5) • Animation with R Sunday, November 22, 2009
    • R • base • • • • lattice • animation Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • library(base) • base • Sunday, November 22, 2009
    • library(MASS) • quine • • Sunday, November 22, 2009
    • histgram(1) Sunday, November 22, 2009
    • histgram(2) par(mfrow=c(2,2)) hist(quine$Days[quine$Age == "F0"]) hist(quine$Days[quine$Age == "F1"]) hist(quine$Days[quine$Age == "F2"]) hist(quine$Days[quine$Age == "F3"]) Sunday, November 22, 2009
    • • • ( ) Sunday, November 22, 2009
    • ... Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • age <- c("F0", "F1", "F2", "F3") for(i in 1:4) { plot(density(quine$Days[quine$Age == age[i]]), col=i, lwd=3, xlim=c(-20, 80), ylim=c(0, 0.08), main="", xlab="", ylab="") par("new"=TRUE) } title("Density of days in each age") legend(40, 0.06, age, lwd=3, col=1:4) Sunday, November 22, 2009
    • ggplot !! Sunday, November 22, 2009
    • ggplot …!! Sunday, November 22, 2009
    • library(ggplot2) q <- ggplot(quine, aes(Days, fill = Age)) q <- q + geom_density(alpha = 0.3) print(q) !! Sunday, November 22, 2009
    • histgram !! q <- ggplot(quine, aes(Days)) q <- q + geom_histogram(binwidth = 10) q <- q + facet_grid( ~ Age) print(q) Sunday, November 22, 2009
    • histgram Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • q <- ggplot(quine, aes(Days)) q <- q + geom_histogram(binwidth = 10) q <- q + facet_grid(Sex ~ Age) print(q) Sunday, November 22, 2009
    • • ? • ? • • →library(lattice) Sunday, November 22, 2009
    • ... Sunday, November 22, 2009
    • lattice library(lattice) histogram(~Days | Age, data=quine) Sunday, November 22, 2009
    • .. • • → orz Sunday, November 22, 2009
    • base lattice ggplot × ×/○ ○ ○ ○ ( ) × ○ × ○ ○ ○ plot × × × ○ × × ○ ○ plot × × Sunday, November 22, 2009
    • ? • ggplot plot Sunday, November 22, 2009
    • • (aes) • ( : ) • plot ( : ) • ggplot reference manual !! Sunday, November 22, 2009
    • Components • Geoms • Statistics • Scales • Coordinate systems • Faceting • Position adujstments • →MECE Sunday, November 22, 2009
    • • ”layer ” • !! Sunday, November 22, 2009
    • ggplot => layer • Photoshop • ( ) • “Statistics” layer http://retouch-weblab.com/kennkyuu/layer/layer1.html Sunday, November 22, 2009
    • layer (1) • q <- ggplot(mtcars, aes(qsec, wt)) • (ggplot plot ) Sunday, November 22, 2009
    • layer (2) • q <- q + stat_smooth() • print(q) Sunday, November 22, 2009
    • layer (3) • q <- q + geom_point() • print(q) • dot ! Sunday, November 22, 2009
    • • “+” ? • ggplot • "%+%" <- `+.ggplot` • ggplot2/R/plot-construction.r Sunday, November 22, 2009
    • • Geom:bar • Stat:bin • Scale:liner • Coordinate system:Cartesian http://had.co.nz/ggplot2/resources/2007-vanderbilt.pdf Sunday, November 22, 2009
    • • Geom:point • Stat:identity • Scale:liner • Coordinate system:Cartesian http://had.co.nz/ggplot2/resources/2007-vanderbilt.pdf Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • layer ? Sunday, November 22, 2009
    • q <- ggplot(mtcars, aes(qsec, wt)) # geoms q <- q + geom_point() # statistics q <- q + stat_smooth() print(q) Sunday, November 22, 2009
    • • kNN method(k ) • • k Sunday, November 22, 2009
    • kNN Sunday, November 22, 2009
    • k=1 Sunday, November 22, 2009
    • prob.c.k.given.x <- function(x,y,k,data){ x1 <- data$x1; x2 <- data$x2 o <- rank(mapply(function(X1,X2){sqrt((X1-x)^2 + (X2- y)^2)},x1,x2)) k.k <- sum(data$class[seq(length(o))[o <= k]] == "r") return(k.k / k) } s <- seq(0, 1, length.out=100) result <- as.data.frame(expand.grid(s, s)) result <- cbind(result, apply(result, 1, function(col) { x <- col[1]; y <- col[2] prob.c.k.given.x(x, y, 1, d) })) colnames(result) <- c("x", "y", "probability") q <- ggplot(result, aes(x = x, y = y)) q <- q + geom_tile(aes(xmin = x, xmax = x + 0.01, ymin = y, ymax = y + 0.01, fill = probability), alpha = 0.1) q <- q + geom_point(data = d, size = 2, aes(x = x1, y = x2, color = factor(class))) q <- q + scale_fill_gradient(low="red", high="blue") print(q) Sunday, November 22, 2009
    • point q <- ggplot(result, aes(x = x, y = y)) # geoms q <- q + geom_tile(aes(xmin = x, xmax = x + 0.01, ymin = y, ymax = y + 0.01, fill = probability), alpha = 0.1) # geoms q <- q + geom_point(data = d, size = 2, aes(x = x1, y = x2, color = factor(class))) # scales q <- q + scale_fill_gradient(low="red", high="blue") print(q) Sunday, November 22, 2009
    • k Sunday, November 22, 2009
    • ? Sunday, November 22, 2009
    • => Faceting q <- q + facet_grid(k ~ .) Sunday, November 22, 2009
    • • ggplot • ( ) • !! Sunday, November 22, 2009
    • • plot • • ? • • Sunday, November 22, 2009
    • • http://had.co.nz/ggplot2/ • http://had.co.nz/ggplot2/resources/2007- vanderbilt.pdf • http://en.wordpress.com/tag/ggplot2/ • http://ito-hi.blog.so-net.ne.jp/tag/ggplot2 • http://d.hatena.ne.jp/ Rion778/20091025/1256508686 Sunday, November 22, 2009
    • Special Thanks • @nozma 95% • !! Sunday, November 22, 2009
    • Sunday, November 22, 2009
    • FAQ Sunday, November 22, 2009
    • ? • orz • Sunday, November 22, 2009
    • ? • • see http://groups.google.com/group/ ggplot2/browse_thread/thread/ beff7d92f05dc741 Sunday, November 22, 2009
    • Sunday, November 22, 2009