Modify Column Names and Types
DESCRIPTION:
This function requires the bigdata library section to be loaded.
USAGE:
bd.modify.columns(data, columns=NULL, names.=NULL, types=NULL,
keep=NULL, drop=NULL)
REQUIRED ARGUMENTS:
OPTIONAL ARGUMENTS:
- data
-
input data set, a
bdFrame
or
data.frame
.
- columns
-
names or numbers of columns to be modified. If NULL, all of the
columns in the input data are specified.
- names.
-
names of output columns. If NULL, use input names. Specifying an
output column name as "" will leave the corresponding input name
unchanged. If this argument is shorter than the number of input
columns, it is extended with "" values. If it is longer, an error
is generated.
- types
-
output column types. If NULL, use input types. Valid types are
"numeric", "factor", "character", "date", or "" (to leave the
input type unchanged). If this is shorter than the number of input
columns, the values are repeated. If it is longer, or if its length
does not divide the number of input columns evenly, an error is
generated.
- keep
-
columns to be output. If NULL and
drop
is
NULL
, select all columns.
- drop
-
columns to be excluded from the output. All other column will be output. Ignored if
keep
is specified.
VALUE:
an object of class
"bdFrame"
or
"data.frame"
,
(the same class as
data
),
with the new specified types, names and select columns.
EXAMPLES:
# Rename fuel.frame's columns to as.character(1:5)
bd.modify.columns(fuel.frame, names(fuel.frame), as.character(1:5))
# Make Disp. a factor column
bd.modify.columns(fuel.frame, "Disp.", types="factor")
# Eliminate Weight column
bd.modify.columns(fuel.frame, keep=2:5)