R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("matlab-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('matlab') Attaching package: 'matlab' The following object(s) are masked from package:utils : find fix > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ceil" > > ### * ceil > > flush(stderr()); flush(stdout()) > > ### Name: ceil > ### Title: MATLAB ceil function > ### Aliases: ceil > ### Keywords: interface > > ### ** Examples > > ceil(c(0.9, 1.3, 2.4)) [1] 1 2 3 > > > > cleanEx(); ..nameEx <- "eye" > > ### * eye > > flush(stderr()); flush(stdout()) > > ### Name: eye > ### Title: MATLAB eye function > ### Aliases: eye > ### Keywords: interface > > ### ** Examples > > eye(3) [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 > > > > cleanEx(); ..nameEx <- "find" > > ### * find > > flush(stderr()); flush(stdout()) > > ### Name: find > ### Title: MATLAB find function > ### Aliases: find > ### Keywords: interface > > ### ** Examples > > find(-3:3 >= 0) [1] 4 5 6 7 > find(c(0, 1, 0, 2, 3)) [1] 2 4 5 > > > > cleanEx(); ..nameEx <- "fix" > > ### * fix > > flush(stderr()); flush(stdout()) > > ### Name: fix > ### Title: MATLAB fix function > ### Aliases: fix > ### Keywords: interface > > ### ** Examples > > fix(c(1.3, 2.5, 3.7)) [1] 1 2 3 > > > > cleanEx(); ..nameEx <- "fliplr" > > ### * fliplr > > flush(stderr()); flush(stdout()) > > ### Name: fliplr > ### Title: MATLAB matrix flip functions > ### Aliases: fliplr fliplr,ANY-method fliplr,array-method > ### fliplr,matrix-method fliplr,missing-method fliplr,vector-method > ### flipud flipud,ANY-method flipud,array-method flipud,matrix-method > ### flipud,missing-method flipud,vector-method > ### Keywords: interface > > ### ** Examples > > fliplr(1:9) [1] 9 8 7 6 5 4 3 2 1 > flipud(1:9) # same as previous since vectors have no orientation in R [1] 9 8 7 6 5 4 3 2 1 > fliplr(matrix(1:9, 3, 3, byrow = TRUE)) [,1] [,2] [,3] [1,] 3 2 1 [2,] 6 5 4 [3,] 9 8 7 > flipud(matrix(1:9, 3, 3, byrow = TRUE)) [,1] [,2] [,3] [1,] 7 8 9 [2,] 4 5 6 [3,] 1 2 3 > > > > cleanEx(); ..nameEx <- "linspace" > > ### * linspace > > flush(stderr()); flush(stdout()) > > ### Name: linspace > ### Title: MATLAB linspace function > ### Aliases: linspace > ### Keywords: interface > > ### ** Examples > > linspace(1, 10, 4) [1] 1 4 7 10 > > > > cleanEx(); ..nameEx <- "logspace" > > ### * logspace > > flush(stderr()); flush(stdout()) > > ### Name: logspace > ### Title: MATLAB logspace function > ### Aliases: logspace > ### Keywords: interface > > ### ** Examples > > logspace(1, pi, 36) [1] 10.000000 9.674596 9.359781 9.055211 8.760551 8.475479 8.199684 [8] 7.932863 7.674725 7.424987 7.183375 6.949625 6.723482 6.504697 [15] 6.293032 6.088255 5.890141 5.698473 5.513043 5.333646 5.160088 [22] 4.992176 4.829729 4.672568 4.520521 4.373422 4.231109 4.093427 [29] 3.960225 3.831358 3.706684 3.586067 3.469376 3.356481 3.247260 [36] 3.141593 > > > > cleanEx(); ..nameEx <- "mod" > > ### * mod > > flush(stderr()); flush(stdout()) > > ### Name: mod > ### Title: MATLAB mod/rem functions > ### Aliases: mod rem > ### Keywords: interface > > ### ** Examples > > # same results with x, y having the same sign > mod(5, 3) [1] 2 > rem(5, 3) [1] 2 > # same results with x, y having different signs > mod(-5, 3) [1] 1 > rem(-5, 3) [1] -2 > > > > cleanEx(); ..nameEx <- "ones" > > ### * ones > > flush(stderr()); flush(stdout()) > > ### Name: ones > ### Title: MATLAB ones/zeros functions > ### Aliases: ones zeros > ### Keywords: interface > > ### ** Examples > > ones(3) [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 > zeros(3) [,1] [,2] [,3] [1,] 0 0 0 [2,] 0 0 0 [3,] 0 0 0 > > > > cleanEx(); ..nameEx <- "pascal" > > ### * pascal > > flush(stderr()); flush(stdout()) > > ### Name: pascal > ### Title: MATLAB pascal function > ### Aliases: pascal > ### Keywords: interface > > ### ** Examples > > pascal(4) [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 2 3 4 [3,] 1 3 6 10 [4,] 1 4 10 20 > pascal(3, 2) [,1] [,2] [,3] [1,] 1 1 1 [2,] -2 -1 0 [3,] 1 0 0 > > > > cleanEx(); ..nameEx <- "repmat" > > ### * repmat > > flush(stderr()); flush(stdout()) > > ### Name: repmat > ### Title: MATLAB repmat function > ### Aliases: repmat > ### Keywords: interface > > ### ** Examples > > repmat(1, 3) # same as ones(3) [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 > repmat(matrix(1:4, 2, 2), 3) [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 3 1 3 1 3 [2,] 2 4 2 4 2 4 [3,] 1 3 1 3 1 3 [4,] 2 4 2 4 2 4 [5,] 1 3 1 3 1 3 [6,] 2 4 2 4 2 4 > > > > cleanEx(); ..nameEx <- "rot90" > > ### * rot90 > > flush(stderr()); flush(stdout()) > > ### Name: rot90 > ### Title: MATLAB rot90 function > ### Aliases: rot90 > ### Keywords: interface > > ### ** Examples > > rot90(matrix(1:4, 2, 2)) [,1] [,2] [1,] 3 4 [2,] 1 2 > > > > cleanEx(); ..nameEx <- "size" > > ### * size > > flush(stderr()); flush(stdout()) > > ### Name: size > ### Title: MATLAB size function > ### Aliases: size size,vector,missing-method size,matrix,integer-method > ### size,matrix,missing-method size,matrix,numeric-method > ### size,array,integer-method size,array,missing-method > ### size,array,numeric-method size,missing-method > ### Keywords: interface > > ### ** Examples > > size(1:8) [1] 8 attr(,"class") [1] "size_t" attr(,"class")attr(,"package") [1] "matlab" > size(matrix(1:8, 2, 4)) [1] 2 4 attr(,"class") [1] "size_t" attr(,"class")attr(,"package") [1] "matlab" > size(matrix(1:8, 2, 4), 2) [1] 4 attr(,"class") [1] "size_t" attr(,"class")attr(,"package") [1] "matlab" > > > > cleanEx(); ..nameEx <- "std" > > ### * std > > flush(stderr()); flush(stdout()) > > ### Name: std > ### Title: MATLAB std function > ### Aliases: std > ### Keywords: interface > > ### ** Examples > > std(1:2) ^ 2 [1] 0.5 > > > > cleanEx(); ..nameEx <- "sum" > > ### * sum > > flush(stderr()); flush(stdout()) > > ### Name: sum > ### Title: MATLAB sum function > ### Aliases: sum sum,ANY-method sum,array,logical-method > ### sum,array,missing-method sum,logical-method sum,matrix,logical-method > ### sum,matrix,missing-method sum,missing-method > ### sum,vector,logical-method sum,vector,missing-method > ### Keywords: interface > > ### ** Examples > > sum(1:9) [1] 45 > sum(matrix(1:9, 3, 3)) [1] 6 15 24 > > > > cleanEx(); ..nameEx <- "tictoc" > > ### * tictoc > > flush(stderr()); flush(stdout()) > > ### Name: tictoc > ### Title: MATLAB timer functions > ### Aliases: tic toc > ### Keywords: interface > > ### ** Examples > > tic() > for(i in 1:100) mad(runif(1000)) # kill time > toc() elapsed time is 0.1 seconds > > > > ### *