Inspect an R object

Share:

Description

Another variant to provide a friendly "whatis" facility.

Usage

1
whatis(ob)

Arguments

ob

An R language object.

Value

NULL

At present, whatis is only used for the side effect of listing object information.

Author(s)

G. Sawitzki

See Also

class mode typeof attributes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 whatis(whatis)
 
## The function is currently defined as
function (ob) {
	obname<-deparse(substitute(ob))
	cat(obname)
	cat(" type=",typeof(ob),sep="")
	cat(" mode=",mode(ob),sep="")
	xx <- class(ob); if (!is.null(xx)) cat(paste(" class:",class(ob)))
	cat(paste(" length=",length(ob)))
	xx <- dim(ob); if (!is.null(xx)) cat(" dim=",xx)
	xx <- names(attributes(ob))
		if (!is.null(xx)) 
			cat("\n"," names(attributes(", obname, "))=",xx,xxsep=" ")
	xx <- dimnames(ob)
	if (!is.null(xx)) { 
		xx <- names(xx)
		if (!is.null(xx)) 
			cat("\n"," names(dimnames(",obname,"))=",xx)
	}
	cat("\n")
	if (typeof(ob)=="expression") {
		cat("expression components: ");str(as.list(ob[[1]]))
	}
  } # whatis