A data frame, a matrix-like structure whose columns may be of differing types (numeric, logical, factor and character and so on).
How the names Of the data frame are created Is complex, And the rest Of this paragraph Is only the basic story. If the arguments are all named And simple objects (Not lists, matrices Of data frames) Then the argument names give the column names. For an unnamed simple argument, a deparsed version Of the argument Is used As the name (With an enclosing I(...) removed). For a named matrix/list/data frame argument With more than one named column, the names Of the columns are the name Of the argument followed by a dot And the column name inside the argument: If the argument Is unnamed, the argument's column names are used. For a named or unnamed matrix/list/data frame argument that contains a single column, the column name in the result is the column name in the argument. Finally, the names are adjusted to be unique and syntactically valid unless check.names = FALSE.
A data frame is a list of variables of the same number of rows with unique row names, given class "data.frame". If no variables are included, the row names determine the number of rows. The column names should be non-empty, And attempts To use empty names will have unsupported results. Duplicate column names are allowed, but you need To use check.names = False For data.frame To generate such a data frame. However, Not all operations On data frames will preserve duplicated column names: For example matrix-Like subsetting will force column names in the result To be unique. data.frame converts each of its arguments to a data frame by calling as.data.frame(optional = TRUE). As that Is a generic function, methods can be written to change the behaviour of arguments according to their classes: R comes With many such methods. Character variables passed To data.frame are converted To factor columns unless Protected by I Or argument stringsAsFactors Is False. If a list Or data frame Or matrix Is passed To data.frame it Is As If Each component Or column had been passed As a separate argument (except For matrices Protected by I). Objects passed To data.frame should have the same number Of rows, but atomic vectors (see Is.vector), factors And character vectors Protected by I will be recycled a whole number Of times If necessary (including As elements Of list arguments). If row names are Not supplied In the Call To data.frame, the row names are taken from the first component that has suitable names, For example a named vector Or a matrix With rownames Or a data frame. (If that component Is subsequently recycled, the names are discarded With a warning.) If row.names was supplied As NULL Or no suitable component was found the row names are the Integer sequence starting at one (And such row names are considered To be 'automatic’, and not preserved by as.matrix). If row names are supplied Of length one And the data frame has a Single row, the row.names Is taken To specify the row names And Not a column (by name Or number). Names are removed from vector inputs Not Protected by I. Default.stringsAsFactors Is a utility that takes getOption("stringsAsFactors") And ensures the result Is TRUE Or FALSE (Or throws an error if the value Is Not NULL).
Chambers, J. M. (1992) Data for models. Chapter 3 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.
04 Members
add``1(String, ``0())
add or replace a column vector
Type Parameters
Parameters
| Name | Type | Description |
key | String | - |
value | ``0() | - |
add``1(String, IEnumerable(Of ``0))
add or replace a column vector
Type Parameters
Parameters
| Name | Type | Description |
key | String | - |
value | IEnumerable(Of ``0) | - |
add(String, Array)
add or replace a column vector
Parameters
| Name | Type | Description |
key | String | - |
value | Array | - |
delete(String())
delete columns from the dataframe.
Parameters
| Name | Type | Description |
keys | String() | - |
detach(String)
delete the specific col and get the deleted col array
Parameters
| Name | Type | Description |
col | String | - |
Returns
this function will returns nothing if the given col is not existed inside the dataframe columns.
getKeyByIndex(Int32)
Parameters
| Name | Type | Description |
index | Int32 | 以1为底的列索引号 |
getVector``1(String())
Remarks
this function returns a vector in full size always
Type Parameters
Parameters
| Name | Type | Description |
synonym | String() | 同意名列表 |
Returns
function may returns nothing if all of the given name is missing from the dataframe object.
(这个函数只会返回碰见的第一个同意名的列数据)
getVector(String, Boolean)
get a vector from column data
Parameters
| Name | Type | Description |
name | String | - |
fullSize | Boolean | the data vector should be fill with the identical value when deal with the scalar value. This function just returns the scalar value by default is the target column contains just one element |
Returns
this function returns nothing if the given name is not exists in the dataframe fields.
ToString
show the dataframe dimension information
projectByColumn(
Array,
Environment,
Boolean,
Boolean,
Boolean)
Parameters
| Name | Type | Description |
selector | Array | - |
reverse | Environment | only works for the character index |
strict | Boolean | the strict option for the dataframe column projection, this option has different behaviours for deal with the missing data column:
for strict mode, an error exception will generates for break the program executation for non-strict mode, the missing column will be added with all element vector is NULL |
Returns
method
sliceByRow
overload 2
#
Remarks
which is true is zero-based by default
Parameters
Parameters
| Name | Type | Description |
selector | Array | accepts:
- logical vector as row selector
- integer vector for take rows by row number
- character vector for take rows by row name
|
method
getRowList
overload 2
#
getRowList(Int32, Boolean)
Parameters
| Name | Type | Description |
index | Int32 | index: integer 0 based |
drop | Boolean | 当drop参数为false的时候,返回一个数组向量 反之返回一个list |
forEachRow(String())
获取得到数据框之中每一行的数据([rowname => columns[]])
Parameters
| Name | Type | Description |
colKeys | String() | - |
getRowIndex(Object)
Parameters
| Name | Type | Description |
any | Object | - |
method
FilterByRowIndex
#
Parameters
| Name | Type | Description |
skips | Int32() | 1-based index to be filter |
env | Environment | - |
Parameters
| Name | Type | Description |
index | Int32() | 以零为底的索引号列表,-1对应的行将会返回空值的行数据 |
Returns
a dataframe object with row subset or an error message
Parameters
| Name | Type | Description |
c | Array | the column data, length of this array data maybe 1 or nrows |
index | Int32() | 索引编号,应该是以零为底的。-1的元素返回空值 |
getRowNames
Returns
this function will generated a index row names automatically if the dataframe.rownames data is nothing, or this function will make a copy of the dataframe.rownames array.
GetRowNumbers
get max length of the column vectors
CreateDataFrame``1(IEnumerable(Of ``0))
Cast a vector of CLR object to a dataframe
Remarks
the class object property used as the dataframe column data
Type Parameters
Parameters
| Name | Type | Description |
data | IEnumerable(Of ``0) | - |
method
CreateDataFrame
overload 2
#
CreateDataFrame``1(IReadOnlyCollection(Of NamedCollection(Of ``0)), IEnumerable(Of String))
Create dataframe from row data
Type Parameters
Parameters
| Name | Type | Description |
rows | IReadOnlyCollection(Of NamedCollection(Of ``0)) | - |
colNames | IEnumerable(Of String) | - |
set column names via names function
Parameters
Example
names(df) = x; ' equals to colnames(df) = x;
hasName(String)
Parameters
| Name | Type | Description |
name | String | - |
columns
the field vectors inside current data frame object, the vector dimension size of the fields could be a scalar value with just one element or vector dimension should equals to the dimension size of dataframe.rownames.
Remarks
nrows
Returns
the row number is tested based on the ncol, if the ncol is zero, then the function GetRowNumbers will returns zero directly.
ncols
the number of the features in current dataframe object
empty
current dataframe object contains any data or not?
Returns
empty is true means contains no rows data or no columns
property
getColumnVector
overload 2
#
getColumnVector(String)
Returns
this property always returns a vector in full size(length is equals to dataframe.nrows), orelse the value null if the given columnName is not exists in the dataframe column fields.
property
getColumnVector
#
getColumnVector(Int32)
dataframe.getKeyByIndex(), get column by 1-based offset
Parameters
| Name | Type | Description |
index | Int32 | - |
rowViews
debug view of this dataframe object in rows, debug used only.
method
getVector
overload 2
#
getVector(String())
method
checkColumnNames
overload 2
#
checkColumnNames(String())
method
checkColumnNames
#
method
CreateDataFrame
overload 2
#
CreateDataFrame(IEnumerable(Of T))
CreateDataFrame(Dictionary(Of String, T()), IEnumerable(Of String))
method
Create
overload 2
#
Create(IEnumerable(Of String), ArgumentReference())
Create(ArgumentReference())