Description Fields Methods See Also Examples
An abstract class for storing data in the form of a data frame. It enforces core functionality that we want the data we model to have. This class covers any data which is stored as list.
This is the full array. For extensibility, it cannot be written to directly and must be modified through methods.
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.
The data associated with each dimension of the array.
The size of the array.
The size of the array.
The data frame this class is responsible for.
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 dimensions of the array.
The number of rows in the data
The names of rows in the data.
A list of metadata associated with the rows of the data.
The tables which make up the relational database.
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 should be extended. Create a new instance of this class.
... | - | This function should take in any arguments just in case. |
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 : FrameData
Is inherited by : AbstractRelationalTables
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | library(dplyr)
library(reshape2)
SampleRelationalTables <- R6Class(
inherit = AbstractRelationalTables,
public = list(
initialize = function(...){
private$.tables = list(...)
if(!all(sapply(private$.tables,function(x){is.data.frame(x)}))){
stop("All arguments must be data frames")
}
},
updateFrame = function(){
private$.frame = Reduce(x = private$.tables,f = left_join)
},
updateArray = function(){
val <- names(self$frame)[1]
dims <- names(self$frame[2:ncol(self$frame)])
private$.arr <- self$frame %>%
group_by_(.dots=setNames(dims,NULL)) %>%
summarize_all(sum) %>%
ungroup() %>%
acast(as.formula(paste(dims,collapse='~')),value.var=val)
mode(private$.arr) = 'numeric'
private$.dims = dim(private$.arr)
private$.nrow = private$.dims[1]
private$.ncol = private$.dims[2]
private$.ndim = length(private$.dims)
private$.dnames = dimnames(private$.arr)
}
),
active = list(
mat = function(value){
if(self$ndim <= 2){
return(self$arr)
}
return(extract(private$.arr,indices = rep(self$ndim-2,x=1),dims = 3:self$ndim,drop=TRUE))
}
)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.