1 R for Windows R Windows Mac OS X Linux Windows 1.1 1.2 R R cat( n ) R R-00.0(00.0 ) etc Rconsole font=tt Courier New font = TT MS Gothic points = 10 points = 14 Rdevga TT Arial TT MS Gothic R demo(japanese) 1.1: R 1
2 R 1 2.1 2.1: R R [ 1.1] [ 2.1] R R R plot() contour() 2
2 3D 3D surface3d() open3d() 2D surface3d() 2.2 100 > 1 + 1 2 > sin( 31 / 432 pi) 0.2235337 R > ( 3 + 2i ) (5 + 9i) -3+37i i > c(1,2,3) c(4,5,6) 4 10 18 c() a b > c(1,2,3) %o% c(4,5,6) 4 5 6 8 10 12 12 15 18 > x <- c(1,2,3) R x > x x sin > x <- seq( 0, 2 pi, length = 100) > plot( sin( x ), type = l ) sin seq() 0 2π 100 > x 0.00000000 0.06346652 0.12693304 0.19039955 0.25386607 0.31733259 0.38079911 6.09278575 6.15625227 6.21971879 6.28318531 100 3
2 2.3.R R ; ; # 2.4 2.1 2.1 1: 2: bunkatu <- 50 ;# 3: hani <- 3 ;# 4: 5: # 6: x <- seq( - hani, hani, length = ( bunkatu + 1 ) ) ; 7: y <- x ; 8: z <- outer( x, y, function( a, b )a + b 1i ) ; 9: 10: # 11: w <- z 2 ; 12: 13: # 14: w[ is.na( w ) ] <- 0 ; 15: 16: u <- Re( w ) ;# 17: v <- Im( w ) ;# 18: 19: # 4
2 20: contour( x, y, u ) 21: contour( x, y, v, add = TRUE )#add = TRUE outer() outer() 2 contour() 5
3 R 3.1 R RGui R 3D rgl Janese(tokyo) OK rgl R library(rgl) > library( ) 3.2 rgl > demo( ) demo(rgl) library(rgl) R > example() 6
3 3.1: rgl 3D example(persp) 3D? graphics lattice image plotmath 3.3 >? > help() html R > help.start() html () > library(help= ) > str() 7
3 > 8
4 rgl 3D 4.1 genkai <- 10 ; bunkatu <- 50 ; hani <- 3 ; x <- seq( - hani, hani, length = ( bunkatu + 1 ) ) ; y <- x ; z <- outer( x, y, function( a, b ) { a + b 1i } ) ; w <- exp( 1 / z ) ; w[ is.na( w ) ] <- genkai ; u <- Re( w ) ; v <- Im( w ) ; u[ which( u >genkai ) ] <- genkai ; v[ which( v >genkai ) ] <- genkai ; u[ which( u <( - genkai ) ) ] <- ( - genkai ) ; v[ which( v <( - genkai ) ) ] <- ( - genkai ) ; open3d( ) ; rgl.bg( color = #6666ff ) surface3d( x, y, u, color = #ff0000, alpha = 0.8, back = lines ) ; surface3d( x, y, v, color = #00ff00, alpha = 0.8, back = lines ) ; genkai 3D bunkatu hani x y w open3d() 3D 3D 9
4 rgl 3D rgl.bg() surface3d help() 10
5 <- >- + - / %% %/% %o% % % ==!= <= >= < >! & && abs() sqrt() round() floor() ceiling() exp() log() 11
5 log2() log10() sin() cos() tan() asin() acos() atan() sign(x) min(x) max(x) sum(x) prod(x) sd(x) cumsum() runif(n) union(x,y) intersect(x,y) unique(x) any(x) all(x) which( ) which.min(x) which.max(x) eigen(x) t(x) outer(a,b) sweep(x,n,a) x x x x x n x,y x,y x x 1 1 x x x n paste(x1,x2, ) function() <- function( 1, ) () a= 12
5 ; for() for R for(i=1;i<5;i++) for(i in 1:4) in i i while while while( ) repeat repeat repeat break break next if if( )else if( )else seq(a,b) sapply(x,f) mapply(f,x1,x2, ) a b 1 length = x : a b x by=x : x x f sapply x setwd( ) getwd() file( ) readlines(con) cat(x,file= ) Sys.time() Sys.Date() con X 1970/1/1 win.metafile() postscript() pdf() pictex() png() jpeg() file= width=a,length=b dev.off() PDF pictex png jpeg 13
5 bmp() tiff() tiff plot(a,b) lines(a,b) abline(a=s,b=k) text(x,y,text) a,b a x b y a,b a x b y s k (x,y) text type = x : x=p l o n () col = #rrggbb : cex = 1: 1 main= popo : sub = coco : xlim,ylim=c(, ): x,y axes = TRUE/FALSE : x,y help(par) rgl.open() rgl.set() rgl.cur() rgl.close() rgl.clear() rgl.pop() rgl.quit() rgl.viewpoint() rgl.light() rgl.bg() rgl.points() rgl.sprites() rgl.lines() rgl.triangles() rgl.surface() rgl.spheres() rgl.snapshot() srgl.bbox() 14