Description Fields Methods See Also Examples
A class for storing a matrix and relevant metaData.
A list of metadata associated with the cells of the data.
The names of columns in the data.
A list of metadata associated with the columns of the data.
A data.frame representation of the IncidenceMatrix. The frame contains all rows/columns as rows of the data frame, and the rows, columns, values and all metadata types as columns. This is similar to the melt function.
This is the matrix. For extensibility, it cannot be written to directly and must be modified through methods.
Any data not part of the main data structure.
The number of columns in the data.
The number of rows in the data
The names of rows in the data.
A list of metadata associated with the columns of the data.
This function adds empty columns to the right side of the data.
columns | - | The number of columns to add. |
This function adds empty rows to the data.
rows | - | The number of rows to add. |
Convert this object to an sts object with as much information as possible
pop_name | - | string with the name of rowData to use as the population of the sts object. |
freq_name | - | string with the name of metaData to use as the frequency of the sts object. |
start_name | - | string with the name of metaData to use as the start of the sts object. |
epoch_name | - | string with the name of the colData to use as the epoch of the sts object. |
map_name | - | string with the name of the rowData to use as the map of the sts object. |
neighbourhood_name | - | string with the name of the rowData to use as the neighbourhood of th ests object. |
A function for debugging the methods of this class. It calls the browser command. In order for methods to opt into to debugging, they need to implement the following code at the beginning: if(<method_name> %in% private$.debug){browser()}. This method exists, because the debugger is not always intuitive when it comes to debugging R6 methods.
string | - | The name(s) of methods to debug as a character vector |
This function replaces the matrix value at column i with the difference. between the values at columns i and (i-lag).
lag | - | How far back to diff. Defaults to 1. |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Select the last k
slices of the data in dimension direction
.
k | - | The number of slices to keep. |
direction | - | The dimension to take a subset of. 1 for row, 2 for column. |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Create a new IncidenceMatrix
object from its components.
data | - | Either a matrix, or an object of class MatrixData. If data is a matrix, it will form the mat field. If data is a MatrixData, then the new object will inherit all of its fields. |
This function replaces the current matrix with a new matrix with one column for every column, and a row for every row/index combination. The column corresponding to the row and index will have the value of the original matrix in the same row, but index columns previous. This shift will introduce NAs where it passes off the end of the matrix.
indices | - | A sequence of lags to use as part of the data. Note that unless this list contains 0, the data will all be shifted back by at least one year. |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
na.rm | - | Whether to remove NA values generated by walking off the edge of the matrix. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
This function replaces the current matrix with a new matrix with one column for every column, and a row for every row/index combination. The column corresponding to the row and index will have the value of the original matrix in the same row, but index columns ahead.
indices | - | A sequence of leads to use as part of the data. Note that unless this list contains 0 , the data will all be shifted foreward by one year. |
mutate | - | Whether to modify this object, or create and return a modified object. |
na.rm | - | Whether to remove the NA columns that result where the lead goes off the edge of self$simulations. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
This function is a way to modify the data as though it were a matrix.
rows | - | Which rows to modify. These can be numeric or names. |
cols | - | Which cols to modify. These can be numeric or names. |
data | - | The data to change the chosen values to. It needs to be the right shape. |
This function rescales each element of our object according to f
f | - | a function which takes in a number and outputs a rescaled version of that number |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Select the data corresponding to the rows rows
and the columns columns
. rows
and columns
can be either numeric or named indices.
rows | - | An row index or list of row indices which can be either numeric or named. |
cols | - | An column index or list of column indices which can be either numeric or named. |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
Select the last k
slices of the data in dimension direction
.
k | - | The number of slices to keep. |
direction | - | The dimension to take a subset of. 1 for row, 2 for column. |
mutate | - | Whether to change the original instance, or create a new one. If FALSE, the instance performing the method will be left unchanged, and a modified copy will be returned. If true, then the instance will modify itself and return nothing. |
If mutate=FALSE
, a clone of this object will run the method and be returned. Otherwise, there is no return.
A function for ceasing to debug methods. Normally a method will call the browser command every time it is run. This command will stop it from doing so.
string | - | The name(s) of the methods to stop debugging. |
Inherits from : AbstractIncidenceMatrix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | data = IncidenceMatrix$new(matrix(1:9,3,3))
data$mat
data$nrow
data$ncol
data$colData = list(1:3,letters[1:3])
data$colData
data$addColumns(2)
data$colData
data$mat
data$diff(1)
data$mat
data$lag(1)
data$mat
data$head(1,1)
data$mat
data$tail(2,2)
data$mat
data$mutate(data=3)
data$mat
data = IncidenceMatrix$new(matrix(1:9,3,3))
data$scale(function(x){x^2},mutate=FALSE)$mat
data$mat
data$subset(rows=1,cols=2)
data$mat
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.