Data Object Management

Data Object Management

The following functions are useful for data object management in R:

class()Identify the class of a named object.
colnames(); rownames()Retrieve or set the column or row names of an object.
dim()Retrieve or set the dimensions of a rectangular data object.
dimnames()Get or set the dim names of an object.
head()Returns the first n rows of a data object.
grep()search for data objects or files based on a pattern within each element of a character vector. See chapter "Misc Tricks" for a full discussion on wind cards and regular expressions.
length()Get or set the length of vectors (including lists) and factors.
ls()returns a vector of character strings giving the names of the objects inn the specified environment (frame or directory). If no environment is specified, ls() shows what data and functions a user has defined.
ls.str()A variation of ls() that also provides data object structure information.
lsf.str()A variation of ls() that also provides information on function objects only.
mode(0set or get the storage mode of a data object.
nchar()Count the number of characters in a character vector.
ncol(); nrow()return the number of columns or rows of a data object.
objects()same as ls().
remove objects from memory. Can be used with pattern recognition
str()Display the internal structure of an R object; a diagnostic function that is very helpful assessing nested lists, geo-spatial objects with several layers and other large data objects with meta data.
summary()Result summary for describing model objects; results depend on data class.
tail()Returns the last n rows of a data object.

Simple Tricks to Manage Objects in Memory

For example, some handy data management commands appear below:

Back | Next