object9: checks the type, the length and the content of some standard...

Description Usage Arguments Details Value Future Examples

View source: R/rbsa0.code.r

Description

checks the type, the length and the content of some standard object. If not correct, a message and a fatal error are issued. NA are detected and considered as wrong or not.
When typ is 'directory' or 'file', x must be a character containing path(s) of directories or files.

Usage

1
2
3
4
 
  object9(x,typ,len=-1,con=numeric(0),
          mensaje=NULL,fatal=TRUE,na.rm=FALSE,
          cla=NULL,speci=NULL) 

Arguments

x

object to be checked.

typ

Character vector indicating the accepted types for the object to be checked. See the code for the list of accepted types, among them 'null', 'integer', 'numeric', 'character', 'logical', 'list', 'any', 'function', 'data.frame', 'matrix','file','directory',... As indicated, 'any' implies that no check of the type is performed.

len

If length(len)==1, the exact length to be checked, if not must be of length two for the possible range of length(x). When -1, no check on the length is performed.
For data.frame, it is the number of columns. When na.rm the check is made after removing the NA values.

con

If length(con)>0, some check about the content of x is done for some of the types. More precisely for (integer, numeric): all values must belong to the interval [con[1],con[2]] and for (character), the set of possible character(1) is described by con.

mensaje

Some additional message to be issued before stopping in case of error.

fatal

what to do when discovering an inconsistency ? TRUE: this function prints the message and stops; FALSE: this function returns the message as a character.

na.rm

Must the NA values be removed before checking? This is implemented only for the types integer, numeric, character and logical.

cla

The class to which the object is supposed to belong. When NULL no check is made with respect to the class.

speci

Some additional specific check for some object types. The following possibilities are implemented:
- NULL when not used,
- "named" to indicate that a vector must be named,
- a matrix with two rows and two column for matrix objects to indicate intervals for the row number (first row) and the column number (second row); NA values means no check,
- a matrix with ndim+1 rows and two columns for array objects to indicate intervals for the number of dimensions and the size of each of them; NA values means no check.

Details

'integer' has not got the meaning in is.integer R standard function. 'null' must be understood as resulting TRUE with function void9.

Value

When everything is OK returns a character(0). If not according to the argument fatal print an error message and stops, or just returns the message as a warning.

Future

(i) improves the treatment of 'NA's; (ii) allows the check of forbidden values

Examples

1
2
3
4
5
 
  object9(letters,c("numeric","character"),c(20,30),mensaje="!OK"); 
  object9(structure("A",.Names="a"),"ncharacter",-1,LETTERS); 
  object9("A","ncharacter",-1,mensaje="BAD",fatal=FALSE); 
  object9(structure("A",.Names="a"),"character",-1,letters,"bad",fatal=FALSE); 

rbsa documentation built on May 2, 2019, 6:07 p.m.