reshape2
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| tuple | 1 | Aggregate two or more sequence |
| melt | 1 | melt: Convert an object into a molten data frame. |
| shift | 1 | shift: Fast lead/lag for vectors and lists lead or lag vectors, lists, data.frames or data.tables implemented in VisualBasic for speed. |
| flip_list | 1 | flip the list key-value pair mapping to value-key pair mapping |
| decompose | 2 | split dataframe by a cell string value split result |
| ConstructDataframe | 1 | Re-construct a dataframe object from a given set of the row data. |
| vector_fill | 1 | fill content which is indexed by a given value list |
| melt_dataframe | 1 | |
| melt_array | 1 | |
| melt_list | 1 |
03 Members
Aggregate two or more sequence
| Name | Type | Description |
|---|---|---|
zip | Object | - |
args | list | - |
env | Environment | - |
melt: Convert an object into a molten data frame.
This the generic melt function. See the following functions for the details about different data structures
| Name | Type | Description |
|---|---|---|
data | Object | Data set to melt |
na_rm | Boolean | Should NA values be removed from the data set? This will convert explicit missings to implicit missings. |
value_name | String | name of variable used to store values |
args | list | further arguments passed To Or from other methods. |
env | Environment | - |
- melt.data.frame for data.frames
- melt.array for arrays, matrices And tables
- melt.list for lists
shift: Fast lead/lag for vectors and lists
lead or lag vectors, lists, data.frames or data.tables implemented in VisualBasic for speed.
shift accepts vectors, lists, data.frames or data.tables. It always returns a list except when the input is a vector and length(n) == 1 in which case a vector is returned, for convenience. This is so that it can be used conveniently within data.table's syntax. For example, DT[, (cols) := shift(.SD, 1L), by=id] would lag every column of .SD by 1 for each group and DT[, newcol := colA + shift(colB)] would assign the sum of two vectors to newcol.
Argument n allows multiple values. For example, DT[, (cols) := shift(.SD, 1:2), by=id] would lag every column of .SD by 1 And 2 for each group. If .SD contained four columns, the first two elements of the list would correspond to lag=1 And lag=2 for the first column of .SD, the next two for second column of .SD And so on. Please see examples for more.
shift Is designed mainly for use in data.tables along with := Or set. Therefore, it returns an unnamed list by default as assigning names for each group over And over can be quite time consuming with many groups. It may be useful to set names automatically in other cases, which can be done by setting give.names to TRUE.
The function behavior is different at here when compare with the shift function of the data.table package from the original R language: the shift function from R language not allow the fill data be nothing, but the shift function in R# language will behavior a different result: when the fill value is nothing at here, this function will becomes skip for type is lag or shift and this function will becomes take for type is lead.
| Name | Type | Description |
|---|---|---|
x | Object | A vector, list, data.frame Or data.table. |
n | Object | integer vector denoting the offset by which to lead or lag the input. To create multiple lead/lag vectors, provide multiple values to n; negative values of n will "flip" the value of type, i.e., n=-1 and type='lead' is the same as n=1 and type='lag'. this parameter could also be a character vector of the names for removes from a given list, if the input x is a tuple list object |
fill | Object | Value to use for padding when the window goes beyond the input length. |
type | Object | default is "lag" (look "backwards"). The other possible values "lead" (look "forwards") and "shift" (behave same as "lag" except given names). |
give_names | Boolean | default is FALSE which returns an unnamed list. When TRUE, names are automatically generated corresponding to type and n. If answer is an atomic vector, then the argument is ignored. |
A list containing the lead/lag of input x.
flip the list key-value pair mapping to value-key pair mapping
this function only works for the value is character vector, null value inside the list will be ignored
| Name | Type | Description |
|---|---|---|
l | list | Should be a tuple list object |
env | Environment | - |
split dataframe by a cell string value split result
| Name | Type | Description |
|---|---|---|
df | dataframe | - |
by | String | the colname for do the cell content split |
split | String | the delimiter string expression for split the cell contents |
env | Environment | - |
split dataframe by a cell string value split result
| Name | Type | Description |
|---|---|---|
df | dataframe | - |
by | Int32 | the column index |
split | String | the delimiter string for split the text in a cell |
env | Environment | - |
A new dataframe object that split by the given column its cell text value
IReadOnlyCollection(Of NamedCollection(Of Object)), String())Re-construct a dataframe object from a given set of the row data.
| Name | Type | Description |
|---|---|---|
rows | IReadOnlyCollection(Of NamedCollection(Of Object)) | the row data collection |
cols | String() | the column names |
fill content which is indexed by a given value list
the length of vector x should be equals to the length of index.
| Name | Type | Description |
|---|---|---|
x | Object | - |
values | list | - |
index | Object | - |
env | Environment | - |