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("R.oo-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('R.oo') R.oo v1.0.3 (2005-05-02) successfully loaded. See ?R.oo for help. > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ASCII" > > ### * ASCII > > flush(stderr()); flush(stdout()) > > ### Name: ASCII > ### Title: 8-bit ASCII table > ### Aliases: ASCII ASCII.BEL ASCII.BS ASCII.HT ASCII.LF ASCII.FF ASCII.CR > ### ASCII.SO ASCII.SI ASCII.DC1 ASCII.DC3 ASCII.ESC > ### Keywords: character internal > > ### ** Examples > > ch <- ASCII[65+1]; # ch == "A" > > > > cleanEx(); ..nameEx <- "DOLLAR.Class" > > ### * DOLLAR.Class > > flush(stderr()); flush(stdout()) > > ### Name: DOLLAR.Class > ### Title: Makes the fields and methods of an Class accessable via the $ > ### and the [[ operator > ### Aliases: $.Class Class.$ $.Class $,Class-method Class.[[ [[.Class > ### [[,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Class). > > > cleanEx(); ..nameEx <- "DOLLAR.Object" > > ### * DOLLAR.Object > > flush(stderr()); flush(stdout()) > > ### Name: DOLLAR.Object > ### Title: Makes the fields and methods of an Object accessable via the $ > ### and the [[ operator > ### Aliases: $.Object Object.$ $.Object $,Object-method Object.[[ [[.Object > ### [[,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "DOLLARLT.-.Class" > > ### * DOLLARLT.-.Class > > flush(stderr()); flush(stdout()) > > ### Name: DOLLAR< -.Class > ### Title: Makes the fields and methods of an Class assignable via the $<- > ### and the [[<- operator > ### Aliases: $<-.Class Class.$<- $<-.Class $<-,Class-method Class.[[<- > ### [[<-.Class [[<-,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Class). > > > cleanEx(); ..nameEx <- "DOLLARLT.-.Object" > > ### * DOLLARLT.-.Object > > flush(stderr()); flush(stdout()) > > ### Name: DOLLAR< -.Object > ### Title: Makes the fields and methods of an Object assignable via the $<- > ### and the [[<- operator > ### Aliases: $<-.Object Object.$<- $<-.Object $<-,Object-method Object.[[<- > ### [[<-.Object [[<-,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "Exception" > > ### * Exception > > flush(stderr()); flush(stdout()) > > ### Name: Exception > ### Title: The Exception class to be thrown and caught > ### Aliases: Exception > ### Keywords: classes programming methods error > > ### ** Examples > > ###################################################################### > # 1. To catch a regular "error" exception thrown by e.g. stop(). > ###################################################################### > x <- NA > y <- NA > tryCatch({ + x <- log(123); + y <- log("a"); + }, error = function(ex) { + print(ex); + }) > print(x) [1] 4.812184 > print(y) [1] NA > > > ###################################################################### > # 2. Always run a "final" expression regardless or error or not. > ###################################################################### > filename <- tempfile("R.methodsS3.example") > con <- file(filename) > tryCatch({ + open(con, "r"); + }, error = function(ex) { + cat("Could not open ", filename, " for reading.\n", sep="") + }, finally = { + close(con) + cat("The id of the connection is ", + ifelse(is.null(con), "NULL", con), ".\n", sep="") + }) Warning: cannot open file '/tmp/RtmpaBnoV9/R.methodsS3.example10d63af1' Could not open /tmp/RtmpaBnoV9/R.methodsS3.example10d63af1 for reading. The id of the connection is 3. > > ###################################################################### > # 3. Creating your own Exception class > ###################################################################### > setConstructorS3("NegativeLogValueException", function( + msg="Trying to calculate the logarithm of a negative value", value=NULL) { + extend(Exception(msg=msg), "NegativeLogValueException", + .value = value + ) + }) > > setMethodS3("as.character", "NegativeLogValueException", function(this) { + paste(as.character.Exception(this), ": ", getValue(this), sep=""); + }) Warning in setMethodS3.default("as.character", "NegativeLogValueException", : Added missing argument '...' to make it more compatible with a generic function: as.character.NegativeLogValueException NULL > > setMethodS3("getValue", "NegativeLogValueException", function(this) { + this$.value; + }) Warning in setMethodS3.default("getValue", "NegativeLogValueException", : Added missing argument '...' to make it more compatible with a generic function: getValue.NegativeLogValueException > > mylog <- function(x, base=exp(1)) { + if (x < 0) + throw(NegativeLogValueException(value=x)) + else + log(x, base=base) + } > > # Note that the order of the catch list is important: > l <- NA; > x <- 123; > tryCatch({ + l <- mylog(x); + }, NegativeLogValueException = function(ex) { + cat(as.character(ex), "\n") + }, "try-error" = function(ex) { + cat("try-error: Could not calculate the logarithm of ", x, ".\n", sep="") + }, error = function(ex) { + cat("error: Could not calculate the logarithm of ", x, ".\n", sep="") + }) > cat("The logarithm of ", x, " is ", l, ".\n\n", sep="") The logarithm of 123 is 4.812184. > > > > > cleanEx(); ..nameEx <- "Object" > > ### * Object > > flush(stderr()); flush(stdout()) > > ### Name: Object > ### Title: The root class that every class must inherit from > ### Aliases: Object > ### Keywords: classes programming methods > > ### ** Examples > > ######################################################################### > # Defines the class Person with private fields .name and .age, and > # with methods print(), getName(), setName(), getAge() and setAge(). > ######################################################################### > setConstructorS3("Person", function(name, age) { + if (missing(name)) name <- NA; + if (missing(age)) age <- NA; + + extend(Object(), "Person", + .name=name, + .age=age + ) + }) > > setMethodS3("as.character", "Person", function(this) { + paste(this$.name, "is", as.integer(this$.age), "years old."); + }) Warning in setMethodS3.default("as.character", "Person", function(this) { : Added missing argument '...' to make it more compatible with a generic function: as.character.Person NULL > > setMethodS3("equals", "Person", function(this, obj) { + ( identical(data.class(this), data.class(obj)) && + identical(this$getName(), obj$getName()) && + identical(this$getAge() , obj$getAge() ) ); + }) Warning in setMethodS3.default("equals", "Person", function(this, obj) { : Added missing argument '...' to make it more compatible with a generic function: equals.Person NULL > > setMethodS3("hashCode", "Person", function(this) { + # Get the hashCode() of the '.name' and the '.age' fields + # using hashCode.default(). + hashCode(this$.name) * hashCode(this$.age); + }) Warning in setMethodS3.default("hashCode", "Person", function(this) { : Added missing argument '...' to make it more compatible with a generic function: hashCode.Person NULL > > setMethodS3("getName", "Person", function(this) { + this$.name; + }) Warning in setMethodS3.default("getName", "Person", function(this) { : Added missing argument '...' to make it more compatible with a generic function: getName.Person NULL > > setMethodS3("setName", "Person", function(this, newName) { + throw("It is not possible to change the name of a Person."); + }) Warning in setMethodS3.default("setName", "Person", function(this, newName) { : Added missing argument '...' to make it more compatible with a generic function: setName.Person > > setMethodS3("getAge", "Person", function(this) { + this$.age; + }) Warning in setMethodS3.default("getAge", "Person", function(this) { : Added missing argument '...' to make it more compatible with a generic function: getAge.Person > > setMethodS3("setAge", "Person", function(this, newAge) { + if (!is.numeric(newAge)) + throw("Age must be numeric: ", newAge); + if (newAge < 0) + throw("Trying to set a negative age: ", newAge); + this$.age <- newAge; + }) Warning in setMethodS3.default("setAge", "Person", function(this, newAge) { : Added missing argument '...' to make it more compatible with a generic function: setAge.Person > > > > ######################################################################### > # Code demonstrating different properties of the Object class using > # the example class Person. > ######################################################################### > > # Create an object (instance of) the class Person. > p1 <- Person("Dalai Lama", 67) > > # 'p1' is an Object of class Person. > print(data.class(p1)) # "Person" [1] "Person" > > # Prints information about the Person object. > print(p1) # "Dalai Lama is 67 years old." [1] "Dalai Lama is 67 years old." > > # or equivalent (except that no generic method has to exist): > > p1$print() # "Dalai Lama is 67 years old." [1] "Dalai Lama is 67 years old." > > # Shows that no generic method is required if the \$ operator is used: > print(p1$getName()) # "Dalai Lama" [1] "Dalai Lama" > > # The following will call p1$getName() since there exists a get-() > # method for the 'name' property. > print(p1$name) # "Dalai Lama" [1] "Dalai Lama" > > # and equivalent when using the [[ operator. > print(p1[["name"]]) # "Dalai Lama" [1] "Dalai Lama" > > # The following shows that p1$setName(68) is called, simply because > # there exists a set-() method for the 'name' property. > p1$age <- 68 # Will call p1$setAge(68) > > # Shows that the age of the Person has been updated: > print(p1) # "Dalai Lama is 68 years old." [1] "Dalai Lama is 68 years old." > > # If there would not exists such a set-() method or field a new > # field would be created: > p1$country <- "Tibet" > > # Lists all (non-private) members of the Person object: > print(ll(p1)) member data.class dimension object.size 1 country character 1 72 > > # which gives > # member class mode typeof length dim bytes > # 1 country NULL character character 1 NULL 44 > > # The following will call p1$setName("Lalai Dama") which will > # throw an exception saying one can not change the name of > # a Person. > tryCatch(p1$name <- "Lalai Dama", error=print) [2005-07-13 10:54:17] Exception: It is not possible to change the name of a Person. at throw(Exception(...)) at throw.default("It is not possible to change the name of a Person.") at throw("It is not possible to change the name of a Person.") at get(setMethodName, mode = "function")(ref, value) at "$<-.Object"(`*tmp*`, "name", value = "Lalai Dama") at "$<-"(`*tmp*`, "name", value = "Lalai Dama") at doTryCatch(return(expr), name, parentenv, handler) at tryCatchOne(expr, names, parentenv, handlers[[1]]) at tryCatchList(expr, classes, parentenv, handlers) at tryCatch(p1$name <- "Lalai Dama", error = print) > > # The following will call p1$setAge(-4) which will throw an > # exception saying that the age must be a non-negative number. > tryCatch(p1$age <- -100, error=print) [2005-07-13 10:54:17] Exception: Trying to set a negative age: -100 at throw(Exception(...)) at throw.default("Trying to set a negative age: ", newAge) at throw("Trying to set a negative age: ", newAge) at get(setMethodName, mode = "function")(ref, value) at "$<-.Object"(`*tmp*`, "age", value = -100) at "$<-"(`*tmp*`, "age", value = -100) at doTryCatch(return(expr), name, parentenv, handler) at tryCatchOne(expr, names, parentenv, handlers[[1]]) at tryCatchList(expr, classes, parentenv, handlers) at tryCatch(p1$age <- -100, error = print) > > # Attaches Object 'p1' to the search path. > attach(p1) > > # Accesses the newly created field 'country'. > print(country) # "Tibet" [1] "Tibet" > > # Detaches Object 'p1' from the search path. Note that all > # modifications to 'country' are lost. > country <- "Sweden" > detach(p1) > print(p1$country) # "Tibet" [1] "Tibet" > > # Saves the Person object to a tempory file. > filename <- tempfile("R.methodsS3.example") > save(p1, filename) > > # Deletes the object > rm(p1) > > # Loads an Object (of "unknown" class) from file using the > # static method load() of class Object. > obj <- Object$load(filename) > > # Prints information about the new Object. > print(obj) [1] "Dalai Lama is 68 years old." > > # Lists all (non-private) members of the new Object. > print(ll(obj)) member data.class dimension object.size 1 country character 1 72 2 exp numeric 1 36 3 object numeric 1 36 4 row character 1 72 5 value character 1 72 > > > > cleanEx(); ..nameEx <- "Package" > > ### * Package > > flush(stderr()); flush(stdout()) > > ### Name: Package > ### Title: The Package class provides methods for accessing package > ### information > ### Aliases: Package > ### Keywords: classes programming methods > > ### ** Examples > ## Not run: # By defining .First.lib() as follows in zzz.R for a package, an > ##D # instance of class Package with the same name as the package will > ##D # be made available on the search path. More over, the code below > ##D # will also inform the user that the package has been loaded: > ##D # > ##D # > library(R.oo) > ##D # R.oo v0.52 (2003/04/13) was successfully loaded. > ##D # > ##D .First.lib <- function(libname, pkgname) { > ##D pkg <- Package(pkgname); > ##D assign(pkgname, pkg, pos=getPosition(pkg)); > ##D cat(getName(pkg), " v", getVersion(pkg), " (", getDate(pkg), ")", > ##D " was successfully loaded.\n", sep=""); > ##D } > ##D > ##D # The Package class works for any packages, loaded or not. > ##D > ##D # Some information about the base package > ##D pkg <- Package("base") > ##D print(pkg) > ##D # [1] "Package: base v1.6.2 (NA) is loaded (pos=5). The official webpage > ##D # is NA and the maintainer is R Core Team . The > ##D # package is installed in c:/PROGRA~1/R/rw1062/library/base/." > ##D print(list.files(Package("base")$dataPath)) > ##D > ##D # Some information about the R.oo package > ##D print(R.oo) > ##D # [1] "Package: R.oo v0.52 (2003/04/13) is loaded (pos=2). The official > ##D # webpage is http://www.braju.com/R/ and the maintainer is Henrik > ##D # Bengtsson . The package is installed in > ##D # c:/PROGRA~1/R/rw1062/library/R.oo/." > ##D > ##D # To check for updates and update a package, just do > ##D update(R.oo) > ##D > ## End(Not run) > > > cleanEx(); ..nameEx <- "RccViolationException" > > ### * RccViolationException > > flush(stderr()); flush(stdout()) > > ### Name: RccViolationException > ### Title: An RccViolationException indicates a violation of the R Coding > ### Conventions (RCC) > ### Aliases: RccViolationException > ### Keywords: classes programming methods error > > ### ** Examples > > ## Not run: > ##D setConstructorS3("myClass", function() { extends(Object(), .value=0) }) > ##D setMethodS3("MyMethod", "myClass", function(this) { "Hullo!" }) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "Rdoc" > > ### * Rdoc > > flush(stderr()); flush(stdout()) > > ### Name: Rdoc > ### Title: Class for converting Rdoc comments to Rd files > ### Aliases: Rdoc > ### Keywords: classes documentation > > ### ** Examples > ## Not run: # Set default author > ##D author <- "Henrik Bengtsson, \url{http://www.braju.com/R/}" > ##D > ##D # Show the file containing the Rdoc comments > ##D rdocFile <- system.file("misc", "Exception.R", package="R.oo") > ##D file.show(rdocFile) > ##D > ##D # Compile the Rdoc:s into Rd files (saved in the destPath directory) > ##D destPath <- tempdir() > ##D Rdoc$compile(rdocFile, destPath=destPath) > ##D > ##D # List the generated Rd files > ##D rdFiles <- list.files(destPath, full.names=TRUE) > ##D print(rdFiles) > ##D > ##D # Show one of the files > ##D file.show(rdFiles[1]) > ##D > ##D # Clean up > ##D file.remove(rdFiles) > ## End(Not run) > > > cleanEx(); ..nameEx <- "argsToString.Class" > > ### * argsToString.Class > > flush(stderr()); flush(stdout()) > > ### Name: argsToString.Class > ### Title: Gets the arguments of a function as a character string > ### Aliases: argsToString.Class Class.argsToString argsToString.Class > ### argsToString,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > Class$argsToString(plot); [[1]] [1] "x" [[2]] [1] "y" [[3]] [1] "..." > > > > cleanEx(); ..nameEx <- "as.character.Class" > > ### * as.character.Class > > flush(stderr()); flush(stdout()) > > ### Name: as.character.Class > ### Title: Returns a short string describing the class > ### Aliases: as.character.Class Class.as.character as.character.Class > ### as.character,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(as.character(Object)) [1] "Class Object has 0 fields and 27 methods." > > # gives: "Class Object: no fields, 8 methods (no inherited)" > > > > cleanEx(); ..nameEx <- "as.character.Exception" > > ### * as.character.Exception > > flush(stderr()); flush(stdout()) > > ### Name: as.character.Exception > ### Title: Gets a character string representing of the Exception > ### Aliases: as.character.Exception Exception.as.character > ### as.character.Exception as.character,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "as.character.Object" > > ### * as.character.Object > > flush(stderr()); flush(stdout()) > > ### Name: as.character.Object > ### Title: Gets a character string representing the object > ### Aliases: as.character.Object Object.as.character as.character.Object > ### as.character,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > as.character(obj) # "Object: 0x016A80FC" [1] "Object: 0x02B34DE4" > > > > cleanEx(); ..nameEx <- "as.character.RccViolationException" > > ### * as.character.RccViolationException > > flush(stderr()); flush(stdout()) > > ### Name: as.character.RccViolationException > ### Title: Gets a string representing of the RCC violation > ### Aliases: as.character.RccViolationException > ### RccViolationException.as.character as.character.RccViolationException > ### as.character,RccViolationException-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "attach.Object" > > ### * attach.Object > > flush(stderr()); flush(stdout()) > > ### Name: attach.Object > ### Title: Attach an Object to the R search path > ### Aliases: attach.Object Object.attach attach.Object attach,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "charToInt" > > ### * charToInt > > flush(stderr()); flush(stdout()) > > ### Name: charToInt > ### Title: Converts a vector of integers into a vector of ASCII characters > ### Aliases: charToInt.default charToInt > ### Keywords: character > > ### ** Examples > > i <- charToInt(unlist(strsplit("Hello world!", split=NULL))) > # Gives: 72 101 108 108 111 32 119 111 114 108 100 33 > ch <- intToChar(c(72,101,108,108,111,32,119,111,114,108,100,33)) > # Gives: "H" "e" "l" "l" "o" " " "w" "o" "r" "l" "d" "!" > > > > cleanEx(); ..nameEx <- "clone.Object" > > ### * clone.Object > > flush(stderr()); flush(stdout()) > > ### Name: clone.Object > ### Title: Clones an Object > ### Aliases: clone.Object Object.clone clone.Object clone,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > o1 <- Object() > o2 <- clone(o1) > > print(equals(o1, o2)) [1] FALSE > > > > cleanEx(); ..nameEx <- "detach.Object" > > ### * detach.Object > > flush(stderr()); flush(stdout()) > > ### Name: detach.Object > ### Title: Detach an Object from the R search path > ### Aliases: detach.Object Object.detach detach.Object detach,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "dimension" > > ### * dimension > > flush(stderr()); flush(stdout()) > > ### Name: dimension > ### Title: Gets the dimension of the object > ### Aliases: dimension.default dimension > ### Keywords: attribute utilities > > ### ** Examples > > dimension(matrix(1:100, ncol=10)) # 10 10 [1] 10 10 > dimension(1:14) # 14 [1] 14 > dimension(data.frame(a=1:10, b=10:1)) # 10 2 [1] 10 2 > dimension(print) # NULL NULL > > > > cleanEx(); ..nameEx <- "equals.Object" > > ### * equals.Object > > flush(stderr()); flush(stdout()) > > ### Name: equals.Object > ### Title: Compares an object with another > ### Aliases: equals.Object Object.equals equals.Object equals,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > o1 <- Object() > o2 <- clone(o1) > equals(o1, o1) # TRUE [1] TRUE > equals(o1, o2) # FALSE [1] FALSE > > > > cleanEx(); ..nameEx <- "extend.Object" > > ### * extend.Object > > flush(stderr()); flush(stdout()) > > ### Name: extend.Object > ### Title: Extends another class > ### Aliases: extend.Object Object.extend extend.Object extend,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "finalize.Object" > > ### * finalize.Object > > flush(stderr()); flush(stdout()) > > ### Name: finalize.Object > ### Title: Finalizer methods called when object is clean out > ### Aliases: finalize.Object Object.finalize finalize.Object > ### finalize,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > setConstructorS3("MyClass", function() { + extend(Object(), "MyClass") + }) > > setMethodS3("finalize", "MyClass", function(this) { + cat(as.character(this), "is about to be removed from the memory!\n") + }) Warning in setMethodS3.default("finalize", "MyClass", function(this) { : Added missing argument '...' to make it more compatible with a generic function: finalize.MyClass NULL > > o <- MyClass() > o <- MyClass() > o <- MyClass() > o <- MyClass() > gc() MyClass: 0x01A53594 is about to be removed from the memory! MyClass: 0x01A7B3AC is about to be removed from the memory! MyClass: 0x01B59D80 is about to be removed from the memory! used (Mb) gc trigger (Mb) max used (Mb) Ncells 187931 5.1 407500 10.9 350000 9.4 Vcells 74717 0.6 786432 6.0 300630 2.3 > > ## Not run: > ##D MyClass: 0x01BE602C is about to be removed from the memory! > ##D MyClass: 0x01BFF634 is about to be removed from the memory! > ##D MyClass: 0x01C13584 is about to be removed from the memory! > ##D MyClass: 0x01C578B0 is about to be removed from the memory! > ##D used (Mb) gc trigger (Mb) > ##D Ncells 229903 6.2 467875 12.5 > ##D Vcells 53725 0.5 786432 6.0 > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "forName.Class" > > ### * forName.Class > > flush(stderr()); flush(stdout()) > > ### Name: forName.Class > ### Title: Gets a Class object by a name of a class > ### Aliases: forName.Class Class.forName forName.Class forName,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(Class$forName("Exception")) Exception extends simpleError, error, condition, try-error, Object { public as.character(...) public getCall(...) public static getLastException(...) public getMessage(...) public getStackTrace(...) public getWhen(...) public print(...) public printStackTrace(...) public throw(...) public showAndWait(...) public $(name) public $<-(name, value) public [[(name) public [[<-(name, value) public attach(private=FALSE, pos=2, ...) public clone(...) public detach(...) public equals(other, ...) public extend(...className, ...) public finalize(...) public getClass(...) public getFields(private=FALSE, ...) public getInstanciationTime(...) public hasField(field, ...) public hashCode(...) public ll(...) public static load(file, path=NULL, ...) public objectSize(...) public save(file=NULL, path=NULL, compress=TRUE, ...) } > > > > cleanEx(); ..nameEx <- "getAuthor.Package" > > ### * getAuthor.Package > > flush(stderr()); flush(stdout()) > > ### Name: getAuthor.Package > ### Title: Gets the Author of this package > ### Aliases: getAuthor.Package Package.getAuthor getAuthor.Package > ### getAuthor,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getAuthor(pkg)) [1] "Henrik Bengtsson " > > > > cleanEx(); ..nameEx <- "getBundle.Package" > > ### * getBundle.Package > > flush(stderr()); flush(stdout()) > > ### Name: getBundle.Package > ### Title: Gets the Bundle that this package might belong to > ### Aliases: getBundle.Package Package.getBundle getBundle.Package > ### getBundle,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getBundle(pkg)) Warning in if (is.na(this$.inBundle)) { : the condition has length > 1 and only the first element will be used NULL > > > > cleanEx(); ..nameEx <- "getBundlePackages.Package" > > ### * getBundlePackages.Package > > flush(stderr()); flush(stdout()) > > ### Name: getBundlePackages.Package > ### Title: Gets the names of the other packages that is in the same bundle > ### as this package > ### Aliases: getBundlePackages.Package Package.getBundlePackages > ### getBundlePackages.Package getBundlePackages,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getBundle(pkg)) Warning in if (is.na(this$.inBundle)) { : the condition has length > 1 and only the first element will be used NULL > > > > cleanEx(); ..nameEx <- "getClasses.Package" > > ### * getClasses.Package > > flush(stderr()); flush(stdout()) > > ### Name: getClasses.Package > ### Title: Gets all classes of a package > ### Aliases: getClasses.Package Package.getClasses getClasses.Package > ### getClasses,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getClasses(pkg)) [1] "BasicObject" "Class" "Exception" [4] "InternalErrorException" "Object" "Package" [7] "RccViolationException" "Rdoc" "RdocException" > > > > cleanEx(); ..nameEx <- "getContribUrl.Package" > > ### * getContribUrl.Package > > flush(stderr()); flush(stdout()) > > ### Name: getContribUrl.Package > ### Title: Gets the URL(s) from where this package can be installed > ### Aliases: getContribUrl.Package Package.getContribUrl > ### getContribUrl.Package getContribUrl,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getContribUrl(pkg)) [1] "http://www.braju.com/R/" > > > > cleanEx(); ..nameEx <- "getDate.Package" > > ### * getDate.Package > > flush(stderr()); flush(stdout()) > > ### Name: getDate.Package > ### Title: Gets the date when package was build > ### Aliases: getDate.Package Package.getDate getDate.Package > ### getDate,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("base") > print(isLoaded(pkg)) # TRUE [1] TRUE > > > > cleanEx(); ..nameEx <- "getDescription.Package" > > ### * getDescription.Package > > flush(stderr()); flush(stdout()) > > ### Name: getDescription.Package > ### Title: Gets the description of the package > ### Aliases: getDescription.Package Package.getDescription > ### getDescription.Package getDescription,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("base") > print(getDescription(pkg)) [1] "Base R functions" > > > > cleanEx(); ..nameEx <- "getDetails.Class" > > ### * getDetails.Class > > flush(stderr()); flush(stdout()) > > ### Name: getDetails.Class > ### Title: Lists the fields and methods of a class > ### Aliases: getDetails.Class Class.getDetails getDetails.Class > ### getDetails,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > getDetails(Exception) > > > > cleanEx(); ..nameEx <- "getDevelUrl.Package" > > ### * getDevelUrl.Package > > flush(stderr()); flush(stdout()) > > ### Name: getDevelUrl.Package > ### Title: Gets the URL(s) from where the developers version of this > ### package can be installed > ### Aliases: getDevelUrl.Package Package.getDevelUrl getDevelUrl.Package > ### getDevelUrl,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getDevelUrl(pkg)) [1] "http://www.maths.lth.se/help/R/" > > > > cleanEx(); ..nameEx <- "getDocPath.Package" > > ### * getDocPath.Package > > flush(stderr()); flush(stdout()) > > ### Name: getDocPath.Package > ### Title: Gets the path to the accompanying documentation (doc/) directory > ### of this package > ### Aliases: getDocPath.Package Package.getDocPath getDocPath.Package > ### getDocPath,Package-method > ### Keywords: methods internal > > ### ** Examples > > print(list.files(getDocPath(R.oo))) # explicit call, or [1] "Bengtsson.pdf" "index.html" > print(list.files(R.oo$docPath)) # as a virtual field [1] "Bengtsson.pdf" "index.html" > > > > cleanEx(); ..nameEx <- "getFields.Class" > > ### * getFields.Class > > flush(stderr()); flush(stdout()) > > ### Name: getFields.Class > ### Title: Returns the field names of a class > ### Aliases: getFields.Class Class.getFields getFields.Class > ### getFields,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(getFields(Exception)) character(0) > > > > cleanEx(); ..nameEx <- "getFields.Object" > > ### * getFields.Object > > flush(stderr()); flush(stdout()) > > ### Name: getFields.Object > ### Title: Returns the field names of an Object > ### Aliases: getFields.Object Object.getFields getFields.Object > ### getFields,Object-method Object.names names.Object names,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > obj$x <- 1:100 > obj$y <- 100:1 > getFields(obj) [1] "x" "y" > > ## Not run: > ##D gives: > ##D > ##D [1] "x" "y" > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getInstanciationTime.Object" > > ### * getInstanciationTime.Object > > flush(stderr()); flush(stdout()) > > ### Name: getInstanciationTime.Object > ### Title: Gets the time when the object was instanciated > ### Aliases: getInstanciationTime.Object Object.getInstanciationTime > ### getInstanciationTime.Object getInstanciationTime,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > print(getInstanciationTime(obj)) [1] "2005-07-13 10:54:36 CEST" > > > > cleanEx(); ..nameEx <- "getInternalAddress.Object" > > ### * getInternalAddress.Object > > flush(stderr()); flush(stdout()) > > ### Name: getInternalAddress.Object > ### Title: Gets the memory location where the Object resides > ### Aliases: getInternalAddress.Object Object.getInternalAddress > ### getInternalAddress.Object getInternalAddress,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > getInternalAddress(obj) # 26979608 [1] 31901576 > > > > cleanEx(); ..nameEx <- "getKnownSubclasses.Class" > > ### * getKnownSubclasses.Class > > flush(stderr()); flush(stdout()) > > ### Name: getKnownSubclasses.Class > ### Title: Gets all subclasses that are currently loaded > ### Aliases: getKnownSubclasses.Class Class.getKnownSubclasses > ### getKnownSubclasses.Class getKnownSubclasses,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > ## Not run: > ##D # Due to a bug in R CMD check (R v1.7.1) the MicroarrayData$read() call > ##D # below will call getKnownSubclasses(), which will generate > ##D # "Error in exists(objectName, mode = "function") : > ##D # [2003-07-07 23:32:41] Exception: F used instead of FALSE" > ##D # Note that the example still work, just not in R CMD check > ##D > ##D print(getKnownSubclasses(Exception)) > ##D > ## End(Not run) > ## Not run: > ##D returns > ##D [1] "Exception" "try-error" "Object" > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getLastException.Exception" > > ### * getLastException.Exception > > flush(stderr()); flush(stdout()) > > ### Name: getLastException.Exception > ### Title: Static method to get the last Exception thrown > ### Aliases: getLastException.Exception Exception.getLastException > ### getLastException.Exception getLastException,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "getLicense.Package" > > ### * getLicense.Package > > flush(stderr()); flush(stdout()) > > ### Name: getLicense.Package > ### Title: Gets the License of this package > ### Aliases: getLicense.Package Package.getLicense getLicense.Package > ### getLicense,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getLicense(pkg)) [1] "GPL version 2 or newer" > > > > cleanEx(); ..nameEx <- "getMaintainer.Package" > > ### * getMaintainer.Package > > flush(stderr()); flush(stdout()) > > ### Name: getMaintainer.Package > ### Title: Gets the Maintainer of this package > ### Aliases: getMaintainer.Package Package.getMaintainer > ### getMaintainer.Package getMaintainer,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getMaintainer(pkg)) [1] "Henrik Bengtsson " > > > > cleanEx(); ..nameEx <- "getMessage.Exception" > > ### * getMessage.Exception > > flush(stderr()); flush(stdout()) > > ### Name: getMessage.Exception > ### Title: Gets the message of the Exception > ### Aliases: getMessage.Exception Exception.getMessage getMessage.Exception > ### getMessage,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "getMethods.Class" > > ### * getMethods.Class > > flush(stderr()); flush(stdout()) > > ### Name: getMethods.Class > ### Title: Returns the method names of class and its super classes > ### Aliases: getMethods.Class Class.getMethods getMethods.Class > ### getMethods,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > l <- getMethods(Exception) > print(l) $Exception as.character getCall "as.character.Exception" "getCall.Exception" getLastException getMessage "getLastException.Exception" "getMessage.Exception" getStackTrace getStackTraceString "getStackTrace.Exception" "getStackTraceString.Exception" getWhen print "getWhen.Exception" "print.Exception" printStackTrace throw "printStackTrace.Exception" "throw.Exception" $simpleError showAndWait "showAndWait.simpleError" $error named character(0) $condition conditionCall conditionMessage "conditionCall.condition" "conditionMessage.condition" $"try-error" named character(0) $Object $ $<- "$.Object" "$<-.Object" [[ [[<- "[[.Object" "[[<-.Object" attach clone "attach.Object" "clone.Object" detach equals "detach.Object" "equals.Object" extend finalize "extend.Object" "finalize.Object" getClass getFields "getClass.Object" "getFields.Object" getInstanciationTime getInternalAddress "getInstanciationTime.Object" "getInternalAddress.Object" getStaticInstance hasField "getStaticInstance.Object" "hasField.Object" hashCode isReferable "hashCode.Object" "isReferable.Object" ll load "ll.Object" "load.Object" names novirtual "names.Object" "novirtual.Object" objectSize save "objectSize.Object" "save.Object" staticCode "staticCode.Object" > > > > cleanEx(); ..nameEx <- "getName.Class" > > ### * getName.Class > > flush(stderr()); flush(stdout()) > > ### Name: getName.Class > ### Title: Gets the name of the class > ### Aliases: getName.Class Class.getName getName.Class getName,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(getName(Object)) # "Object" [1] "Object" > print(getName(Class)) # "Class" [1] "Class" > > > > cleanEx(); ..nameEx <- "getPackage.Class" > > ### * getPackage.Class > > flush(stderr()); flush(stdout()) > > ### Name: getPackage.Class > ### Title: Gets the package to which the class belongs > ### Aliases: getPackage.Class Class.getPackage getPackage.Class > ### getPackage,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(getPackage(Object)) [1] "R.oo" > > > > cleanEx(); ..nameEx <- "getPosition.Package" > > ### * getPosition.Package > > flush(stderr()); flush(stdout()) > > ### Name: getPosition.Package > ### Title: Gets the search path position of the package > ### Aliases: getPosition.Package Package.getPosition getPosition.Package > ### getPosition,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("base") > print(getPosition(pkg)) [1] 11 > > > > cleanEx(); ..nameEx <- "getRccUrl.RccViolationException" > > ### * getRccUrl.RccViolationException > > flush(stderr()); flush(stdout()) > > ### Name: getRccUrl.RccViolationException > ### Title: Static method to get a URL where the RCC can be found > ### Aliases: getRccUrl.RccViolationException > ### RccViolationException.getRccUrl getRccUrl.RccViolationException > ### getRccUrl,RccViolationException-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(RccViolationException). > > > cleanEx(); ..nameEx <- "getStackTrace.Exception" > > ### * getStackTrace.Exception > > flush(stderr()); flush(stdout()) > > ### Name: getStackTrace.Exception > ### Title: Gets the stack trace saved when the exception was created > ### Aliases: getStackTrace.Exception Exception.getStackTrace > ### getStackTrace.Exception getStackTrace,Exception-method > ### Exception.getCall getCall.Exception getCall,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "getStaticInstance.Class" > > ### * getStaticInstance.Class > > flush(stderr()); flush(stdout()) > > ### Name: getStaticInstance.Class > ### Title: Gets the static instance of this class > ### Aliases: getStaticInstance.Class Class.getStaticInstance > ### getStaticInstance.Class getStaticInstance,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- getStaticInstance(Object) > > > > cleanEx(); ..nameEx <- "getStaticInstance.Object" > > ### * getStaticInstance.Object > > flush(stderr()); flush(stdout()) > > ### Name: getStaticInstance.Object > ### Title: Gets the static instance of this objects class > ### Aliases: getStaticInstance.Object Object.getStaticInstance > ### getStaticInstance.Object getStaticInstance,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > ex <- Exception("Oops!") > obj <- getStaticInstance(ex) > > > > cleanEx(); ..nameEx <- "getSuperclasses.Class" > > ### * getSuperclasses.Class > > flush(stderr()); flush(stdout()) > > ### Name: getSuperclasses.Class > ### Title: Gets the super classes of this class > ### Aliases: getSuperclasses.Class Class.getSuperclasses > ### getSuperclasses.Class getSuperclasses,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(getSuperclasses(RccViolationException)) [1] "Exception" "simpleError" "error" "condition" "try-error" [6] "Object" > ## Not run: > ##D returns > ##D [1] "Exception" "try-error" "Object" > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getTitle.Package" > > ### * getTitle.Package > > flush(stderr()); flush(stdout()) > > ### Name: getTitle.Package > ### Title: Gets the Title of this package > ### Aliases: getTitle.Package Package.getTitle getTitle.Package > ### getTitle,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getTitle(pkg)) [1] "R object-oriented programming with or without references" > > > > cleanEx(); ..nameEx <- "getUrl.Package" > > ### * getUrl.Package > > flush(stderr()); flush(stdout()) > > ### Name: getUrl.Package > ### Title: Gets the URL of this package > ### Aliases: getUrl.Package Package.getUrl getUrl.Package > ### getUrl,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("R.oo") > print(getUrl(pkg)) [1] "http://www.braju.com/R/" > > > > cleanEx(); ..nameEx <- "getWhen.Exception" > > ### * getWhen.Exception > > flush(stderr()); flush(stdout()) > > ### Name: getWhen.Exception > ### Title: Gets the time when the Exception was created > ### Aliases: getWhen.Exception Exception.getWhen getWhen.Exception > ### getWhen,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "hasField.Object" > > ### * hasField.Object > > flush(stderr()); flush(stdout()) > > ### Name: hasField.Object > ### Title: Checks if a field exists or not > ### Aliases: hasField.Object Object.hasField hasField.Object > ### hasField,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > obj$x <- 1:100 > obj$y <- 100:1 > hasField(obj, c("x", "a", "b", "y")) [1] TRUE FALSE FALSE TRUE > > ## Not run: > ##D gives: > ##D > ##D [1] TRUE FALSE FALSE TRUE > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "hashCode.Object" > > ### * hashCode.Object > > flush(stderr()); flush(stdout()) > > ### Name: hashCode.Object > ### Title: Gets a hash code for the Object > ### Aliases: hashCode.Object Object.hashCode hashCode.Object > ### hashCode,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > hashCode(obj) # 26979608 [1] 30550288 > > > > cleanEx(); ..nameEx <- "intToChar" > > ### * intToChar > > flush(stderr()); flush(stdout()) > > ### Name: intToChar > ### Title: Converts a vector of ASCII characters into a vector of integers > ### Aliases: intToChar.default intToChar > ### Keywords: character > > ### ** Examples > > i <- charToInt(unlist(strsplit("Hello world!", split=NULL))) > # Gives: 72 101 108 108 111 32 119 111 114 108 100 33 > ch <- intToChar(c(72,101,108,108,111,32,119,111,114,108,100,33)) > # Gives: "H" "e" "l" "l" "o" " " "w" "o" "r" "l" "d" "!" > > > > cleanEx(); ..nameEx <- "isAbstract.Class" > > ### * isAbstract.Class > > flush(stderr()); flush(stdout()) > > ### Name: isAbstract.Class > ### Title: Checks if a class is abstract or not > ### Aliases: isAbstract.Class Class.isAbstract isAbstract.Class > ### isAbstract,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > if (isAbstract(RccViolationException)) + throw("The class RccViolationException should NOT be abstract.") > > > > cleanEx(); ..nameEx <- "isLoaded.Package" > > ### * isLoaded.Package > > flush(stderr()); flush(stdout()) > > ### Name: isLoaded.Package > ### Title: Checks if the package is installed on the search path or not > ### Aliases: isLoaded.Package Package.isLoaded isLoaded.Package > ### isLoaded,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("base") > print(isLoaded(pkg)) # TRUE [1] TRUE > > > > cleanEx(); ..nameEx <- "isPrivate.Class" > > ### * isPrivate.Class > > flush(stderr()); flush(stdout()) > > ### Name: isPrivate.Class > ### Title: Checks if a class is defined private or not > ### Aliases: isPrivate.Class Class.isPrivate isPrivate.Class > ### isPrivate,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > if (isPrivate(RccViolationException)) + throw("The class RccViolationException should NOT be private.") > > > > cleanEx(); ..nameEx <- "isProtected.Class" > > ### * isProtected.Class > > flush(stderr()); flush(stdout()) > > ### Name: isProtected.Class > ### Title: Checks if a class is defined protected or not > ### Aliases: isProtected.Class Class.isProtected isProtected.Class > ### isProtected,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > if (isProtected(RccViolationException)) + throw("The class RccViolationException should NOT be protected.") > > > > cleanEx(); ..nameEx <- "isPublic.Class" > > ### * isPublic.Class > > flush(stderr()); flush(stdout()) > > ### Name: isPublic.Class > ### Title: Checks if a class is defined public or not > ### Aliases: isPublic.Class Class.isPublic isPublic.Class > ### isPublic,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > if (!isPublic(RccViolationException)) + throw("The class RccViolationException should be public.") > > > > cleanEx(); ..nameEx <- "isStatic.Class" > > ### * isStatic.Class > > flush(stderr()); flush(stdout()) > > ### Name: isStatic.Class > ### Title: Checks if a class is static or not > ### Aliases: isStatic.Class Class.isStatic isStatic.Class > ### isStatic,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > if (!isStatic(RccViolationException)) + throw("RccViolationException should be static because Exception is.") > > > > cleanEx(); ..nameEx <- "ll.Object" > > ### * ll.Object > > flush(stderr()); flush(stdout()) > > ### Name: ll.Object > ### Title: Generates a list of informative properties of all members of an > ### Object > ### Aliases: ll.Object Object.ll ll.Object ll,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > obj$x <- 1:100 > obj$y <- 100:1 > ll(obj) member data.class dimension object.size 1 x numeric 100 428 2 y numeric 100 428 > > ## Not run: > ##D gives: > ##D > ##D member class mode typeof length dim bytes > ##D 1 x NULL numeric integer 100 NULL 428 > ##D 2 y NULL numeric integer 100 NULL 428 > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "ll.Package" > > ### * ll.Package > > flush(stderr()); flush(stdout()) > > ### Name: ll.Package > ### Title: Generates a list of informative properties of all members of the > ### package > ### Aliases: ll.Package Package.ll ll.Package ll,Package-method > ### Keywords: methods internal > > ### ** Examples > > ## Not run: ll(R.oo) > > > > cleanEx(); ..nameEx <- "ll" > > ### * ll > > flush(stderr()); flush(stdout()) > > ### Name: ll > ### Title: Generates a list of informative properties of all members of an > ### environment > ### Aliases: ll.default ll > ### Keywords: utilities > > ### ** Examples > > ## Not run: > ##D To list all objects in .GlobalEnv: > ##D > ll() > ##D member data.class dimension object.size > ##D 1 *tmp* Person 1 428 > ##D 2 as.character.Person function NULL 1208 > ##D 3 country character 1 44 > ##D 4 equals.Person function NULL 2324 > ##D 5 filename character 1 84 > ##D 6 getAge function NULL 372 > ##D 7 getAge.Person function NULL 612 > ##D 8 getName.Person function NULL 628 > ##D 9 hashCode.Person function NULL 1196 > ##D 10 last.warning list 1 192 > ##D 11 obj Person 1 428 > ##D 12 Person Class NULL 2292 > ##D 13 setAge function NULL 372 > ##D 14 setAge.Person function NULL 2088 > ##D 15 setName function NULL 372 > ##D 16 setName.Person function NULL 760 > ##D 17 staticCode.Person function NULL 2372 > ##D > ##D To list all functions in the methods package: > ##D ll(mode="function", envir="methods") > ##D > ##D To list all numeric and character object in the base package: > ##D ll(mode=c("numeric", "character"), envir="base") > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "load.Object" > > ### * load.Object > > flush(stderr()); flush(stdout()) > > ### Name: load.Object > ### Title: Static method to load an Object from a file or a connection > ### Aliases: load.Object Object.load load.Object load,Object-method > ### Keywords: methods internal programming methods IO > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "load.Package" > > ### * load.Package > > flush(stderr()); flush(stdout()) > > ### Name: load.Package > ### Title: Loads a package > ### Aliases: load.Package Package.load load.Package load,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("base") > print(load(pkg)) [1] TRUE > > > > cleanEx(); ..nameEx <- "newInstance.Class" > > ### * newInstance.Class > > flush(stderr()); flush(stdout()) > > ### Name: newInstance.Class > ### Title: Creates a new instance of this class > ### Aliases: newInstance.Class Class.newInstance newInstance.Class > ### newInstance,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- newInstance(Object) > > # equivalent to > > obj <- Object() > > > > cleanEx(); ..nameEx <- "objectSize.Object" > > ### * objectSize.Object > > flush(stderr()); flush(stdout()) > > ### Name: objectSize.Object > ### Title: Gets the size of the Object in bytes > ### Aliases: objectSize.Object Object.objectSize objectSize.Object > ### objectSize,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > > obj <- Object() > obj$x <- 1:100 > obj$y <- 100:1 > objectSize(obj) # 856 [1] 856 > > > > cleanEx(); ..nameEx <- "print.Class" > > ### * print.Class > > flush(stderr()); flush(stdout()) > > ### Name: print.Class > ### Title: Prints detailed information about the class and its fields and > ### methods > ### Aliases: print.Class Class.print print.Class print,Class-method > ### Keywords: methods internal programming methods > > ### ** Examples > > print(Object) Object public $(name) public $<-(name, value) public [[(name) public [[<-(name, value) public as.character(...) public attach(private=FALSE, pos=2, ...) public clone(...) public detach(...) public equals(other, ...) public extend(...className, ...) public finalize(...) public getClass(...) public getFields(private=FALSE, ...) public getInstanciationTime(...) public hasField(field, ...) public hashCode(...) public ll(...) public static load(file, path=NULL, ...) public objectSize(...) public print(...) public save(file=NULL, path=NULL, compress=TRUE, ...) } > > > > cleanEx(); ..nameEx <- "print.Exception" > > ### * print.Exception > > flush(stderr()); flush(stdout()) > > ### Name: print.Exception > ### Title: Prints the Exception > ### Aliases: print.Exception Exception.print print.Exception > ### print,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "print.Object" > > ### * print.Object > > flush(stderr()); flush(stdout()) > > ### Name: print.Object > ### Title: Prints an Object > ### Aliases: print.Object Object.print print.Object print,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "printStackTrace.Exception" > > ### * printStackTrace.Exception > > flush(stderr()); flush(stdout()) > > ### Name: printStackTrace.Exception > ### Title: Prints the stack trace saved when the exception was created > ### Aliases: printStackTrace.Exception Exception.printStackTrace > ### printStackTrace.Exception printStackTrace,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "reportBug.InternalErrorException" > > ### * reportBug.InternalErrorException > > flush(stderr()); flush(stdout()) > > ### Name: reportBug.InternalErrorException > ### Title: Send a bug report > ### Aliases: reportBug.InternalErrorException > ### InternalErrorException.reportBug reportBug.InternalErrorException > ### reportBug,InternalErrorException-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: library(R.colors) > ##D > ##D myLog <- function(x, ...) { > ##D if (!is.numeric(x)) { > ##D throw(InternalErrorException("Argument 'x' to myLog() is not numeric: ", mode(x), package=R.colors)) > ##D } > ##D log(x, ...) > ##D } > ##D > ##D myLog(2) > ##D > ##D ex <- NULL > ##D trycatch({ > ##D myLog("a") > ##D }, ANY={ > ##D ex <- Exception$getLastException() > ##D }) > ## End(Not run) > > > cleanEx(); ..nameEx <- "save.Object" > > ### * save.Object > > flush(stderr()); flush(stdout()) > > ### Name: save.Object > ### Title: Saves an Object to a file or a connection > ### Aliases: save.Object Object.save save.Object save,Object-method > ### Keywords: methods internal programming methods IO > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "setConstructorS3" > > ### * setConstructorS3 > > flush(stderr()); flush(stdout()) > > ### Name: setConstructorS3 > ### Title: Defines a class in S3/UseMethod style > ### Aliases: setConstructorS3.default setConstructorS3 > ### Keywords: programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "setGenericS3" > > ### * setGenericS3 > > flush(stderr()); flush(stdout()) > > ### Name: setGenericS3 > ### Title: Creates a generic function in S3/UseMethod style > ### Aliases: setGenericS3.default setGenericS3 > ### Keywords: programming methods internal > > ### ** Examples > > myCat.matrix <- function(..., sep=", ") { + cat("A matrix:\n"); + cat(..., sep=sep); + cat("\n"); + } > > myCat.default <- function(..., sep=", ") { + cat(..., sep=sep); + cat("\n"); + } > > setGenericS3("myCat"); > > myCat(1:10); 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 > mat <- matrix(1:10, ncol=5); > attr(mat, "class") <- "matrix"; # Has to be done as of [R] V1.4.0. > myCat(mat); A matrix: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 > > > > cleanEx(); ..nameEx <- "setMethodS3" > > ### * setMethodS3 > > flush(stderr()); flush(stdout()) > > ### Name: setMethodS3 > ### Title: Creates a method for a class using S3/UseMethod style > ### Aliases: setMethodS3.default setMethodS3 > ### Keywords: programming methods > > ### ** Examples > > ###################################################################### > # Example 1 > ###################################################################### > setMethodS3("foo", "default", function(x, ...) { + cat("In default foo():\n"); + print(x, ...); + }) > > setMethodS3("foo", "character", function(s, ...) { + cat("In foo() for class 'character':\n"); + print(s, ...); + }) NULL > > # The generic function is automatically created! > print(foo) function (...) UseMethod("foo") > > foo(123) In default foo(): [1] 123 > foo("123") In foo() for class 'character': [1] "123" > > ###################################################################### > # Example 2 > # > # Assume that in a loaded package there is already a function bar(), > # but you also want to use the name 'bar' for the character string. > # It may even be the case that you do not know of the other package, > # but your users do! > ###################################################################### > # bar() in other package > bar <- function(x, y, ...) { + cat("In bar() of 'other' package.\n"); + } > > # Your defintion; will redefine bar() above to bar.default(). > setMethodS3("bar", "character", function(object, ...) { + cat("In bar() for class 'character':\n"); + print(object, ...); + }) Warning in setGenericS3.default(name, envir = envir) : Renamed the preexisting function bar to bar.default, which was defined in environment base. > > bar(123) In bar() of 'other' package. > bar("123") In bar() for class 'character': [1] "123" > > > > ## Not run: For a complete example see help(Object). > > > > cleanEx(); ..nameEx <- "showAndWait.simpleError" > > ### * showAndWait.simpleError > > flush(stderr()); flush(stdout()) > > ### Name: showAndWait.simpleError > ### Title: Display the message to the user and wait for the user to respond > ### Aliases: showAndWait.simpleError simpleError.showAndWait > ### showAndWait.simpleError showAndWait,simpleError-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: > ##D tryCatch({ > ##D log("a"); > ##D }, error = function(ex) { > ##D showAndWait(ex); > ##D }) > ## End(Not run) > > > cleanEx(); ..nameEx <- "staticCode.Object" > > ### * staticCode.Object > > flush(stderr()); flush(stdout()) > > ### Name: staticCode.Object > ### Title: Method that will be call each time a new instance of a class is > ### created > ### Aliases: staticCode.Object Object.staticCode staticCode.Object > ### staticCode,Object-method > ### Keywords: methods internal programming methods > > ### ** Examples > ## Not run: For a complete example see help(Object). > > > cleanEx(); ..nameEx <- "throw.Exception" > > ### * throw.Exception > > flush(stderr()); flush(stdout()) > > ### Name: throw.Exception > ### Title: Throws an Exception that can be caught > ### Aliases: throw.Exception Exception.throw throw.Exception > ### throw,Exception-method > ### Keywords: methods internal programming methods error > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "throw" > > ### * throw > > flush(stderr()); flush(stdout()) > > ### Name: throw > ### Title: Throws an Exception > ### Aliases: throw.default throw > ### Keywords: error > > ### ** Examples > > rbern <- function(n=1, prob=1/2) { + if (prob < 0 || prob > 1) + throw("Argument 'prob' is out of range: ", prob) + rbinom(n=n, size=1, prob=prob) + } > > rbern(10, 0.4) [1] 0 0 0 1 0 1 1 1 1 0 > # [1] 0 1 0 0 0 1 0 0 1 0 > tryCatch(rbern(10, 10*0.4), + error=function(ex) {} + ) NULL > > > > cleanEx(); ..nameEx <- "trycatch" > > ### * trycatch > > flush(stderr()); flush(stdout()) > > ### Name: trycatch > ### Title: Evaluates an expression with the possibility to catch exceptions > ### (DEPRECATED) > ### Aliases: trycatch > ### Keywords: error internal > > ### ** Examples > ## Not run: For a complete example see help(Exception). > > > cleanEx(); ..nameEx <- "unload.Package" > > ### * unload.Package > > flush(stderr()); flush(stdout()) > > ### Name: unload.Package > ### Title: Unloads a package > ### Aliases: unload.Package Package.unload unload.Package > ### unload,Package-method > ### Keywords: methods internal > > ### ** Examples > > pkg <- Package("boot") > load(pkg) [1] TRUE > print(isLoaded(pkg)) [1] TRUE > unload(pkg) > print(isLoaded(pkg)) [1] FALSE > > > > cleanEx(); ..nameEx <- "update.Package" > > ### * update.Package > > flush(stderr()); flush(stdout()) > > ### Name: update.Package > ### Title: Updates the package is a newer version is available > ### Aliases: update.Package Package.update update.Package > ### update,Package-method > ### Keywords: methods internal > > ### ** Examples > ## Not run: update(R.oo) > > > ### *