Construct a Data Frame Object

USAGE:

data.frame(..., row.names, check.rows=F, check.names=T,  
           na.strings="NA", dup.row.names=F, stringsAsFactors=<<see below>>) 
data.frameAux(x, ...) 
as.data.frame(x, row.names=NULL,  stringsAsFactors=<<see below>>, ...) 
is.data.frame(x) 

ARGUMENTS:

...
objects to be included in the data frame. These can be vectors (numeric, character, or logical), factors, numeric matrices, lists, or other data frames. Matrices, lists, and data frames provide as many variables to the new data frame as they have columns, elements, or variables, respectively.
The treatment of objects appearing in a call depends on the existence of corresponding methods for data.frameAux(); see the note on methods below.
For data.frameAux the ... argument plays a different role, allowing optional arguments to be passed to methods for these generic functions. For data.frameAux the ... argument can be a bdFrame.
row.names
a (character) vector giving row names for the data frame. Otherwise, row names are taken from the dimnames attribute of a matrix argument, from the row.names argument of a previous data frame, the names of a vector, or the row numbers. Supplying the argument explicitly as NULL forces the row numbers to be used.
check.rows
logical flag; if TRUE, the rows are checked for consistency. If several arguments imply row names, the function will check that these names are consistent. Generally only useful in computations that claim to have selected the same rows from several parallel sources of data. This argument is ignored if row.names is supplied.
check.names
logical flag; if TRUE, then variable names are made into legal S object names by substituting . for illegal characters like blanks, parentheses, or commas (see for details).
na.strings
Character vector. When character valued input columns are converted from factors, values found in na.strings are considered to be missing values. The default is "NA". character(0) means that no strings will be considered missing values.
dup.row.names
logical; if TRUE then duplicate row names are allowed. The result may be much faster to create and subscript (particularly for bootstrapping) if there are many rows.
stringsAsFactors
a logical flag; if TRUE then convert character arguments to factors whose levels are the unique strings in the argument. This may save time and space if there a many repeated values in the strings and may make the statistical modelling functions easier to use. The default is TRUE, unless one sets options(stringsAsFactors=FALSE).
x
an object to be coerced to be a data frame. This object can be anything representing one or more variables of a data frame; for example, a vector representing a single column or a matrix representing multiple columns.

VALUE:

in the case of data.frame(), a data frame consisting of all the variables supplied in the arguments. The variables are required to have the same number of observations. A data.frame is a list whose elements are variables. The data frame will always have an attribute "row.names" containing the row names, attribute "names" containing names of the variables, which are normally unique, and class "data.frame". It may also have an attribute "dup.row.names", which, if non-null, indicates that row names need not be unique.

In the case of data.frameAux(), the single argument will be coerced to a list whose elements are variables with the same number of observations. Columns of a matrix and elements of a list will normally become individual variables. Attributes "names" and "row.names" may be attached, particular if they can be obtained naturally from x (e.g. from column and row names of a matrix, respectively); data.frameAux does not check these for uniqueness.

In the case of as.data.frame(), like data.frameAux() except that the "names" and "row.names" must be present and unique, and the value has class "data.frame".

METHODS:

data.frame calls data.frameAux for each of its data arguments. data.frameAux is a generic function, so that a method can be written for a new class of objects to overrule the normal behavior described above.
as.data.frame is also a generic function. The default version of this function calls data.frameAux, then attaches unique row.names and names attributes and the "data.frame" class.

DETAILS:

In data.frame, row.names could also be a numeric index or name indicating a variable to use as row names rather than as a variable. This behavior is deprecated due to ambiguity in some cases, e.g. when objects contribute multiple columns.

SEE ALSO:

, , , , .

EXAMPLES:

data.frame(state.x77) 
data.frame(state.x77, row.names=state.abb) 
data.frame(state.x77, dup.row.names=T)  # for faster bootstrap 
# The following are roughly equivalent except for speed 
data.frame(scan("myfile", what=list(a=0,b=0,c=""))) 
data.frame(scan("myfile", what=list(a=0,b=0,c="")), dup.row.names=T) 
as.data.frame(scan("myfile", what=list(a=0,b=0,c=""))) 
read.table("myfile")