Title: | Combines 'data.table' and 'matrix' Classes |
---|---|
Description: | Provides two classes extending 'data.table' class. Simple 'tableList' class wraps 'data.table' and any additional structures together. More complex 'tableMatrix' class combines 'data.table' and 'matrix'. See <http://github.com/InferenceTechnologies/tableMatrix> for more information and examples. |
Authors: | Petr Lenhard [aut, cre], Inference Technologies [cph], Petra Hudeckova [ctb] |
Maintainer: | Petr Lenhard <[email protected]> |
License: | GPL-2 |
Version: | 0.82.0 |
Built: | 2024-12-22 06:29:52 UTC |
Source: | CRAN |
tableList
method, passes data.table bracket functionality to the table attribute.
Usage is the same as in data.table[] and data.table[] <-.
Assigning works only for tab
part and only i
and j
from data.table
is used.
Bracket
## S3 method for class 'tableList' x[...] ## S3 replacement method for class 'tableList' x[i, j] <- value
## S3 method for class 'tableList' x[...] ## S3 replacement method for class 'tableList' x[i, j] <- value
x |
|
... |
Passed arguments. |
i |
Same as |
j |
Same as |
value |
Value to be set. |
tableList
or vector.
data(images8By8) # Create tableList from images8By8[,1:3] TL <- tableList(images8By8[,1:3]) # Apply data.table bracket on a tableList object TL[direction=="both"] TL[2,1] <- "aaa" # setting row TL[2,] <- list("aaa", 1000, 1000) # setting column TL[,2] <- 1
data(images8By8) # Create tableList from images8By8[,1:3] TL <- tableList(images8By8[,1:3]) # Apply data.table bracket on a tableList object TL[direction=="both"] TL[2,1] <- "aaa" # setting row TL[2,] <- list("aaa", 1000, 1000) # setting column TL[,2] <- 1
tableMatrix
method, passes data.table bracket functionality to the table attribute.
Assigning works only for tab
part and only i
and j
from data.table
is used. If j
is numeric, it corresponds to first attribute after tmName
names.
Bracket
## S3 method for class 'tableMatrix' x[...] ## S3 replacement method for class 'tableMatrix' x[i, j] <- value
## S3 method for class 'tableMatrix' x[...] ## S3 replacement method for class 'tableMatrix' x[i, j] <- value
x |
|
... |
Passed arguments. |
i |
Same as |
j |
Same as |
value |
Value to be set. |
tableMatrix
or vector.
data(images8By8) # Create tableMatrix from images8By8 TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) TM[2,1] <- "aaa" TM[1,"dimX"] <- 1000 # setting row TM[2,] <- list("aaa", 1000, 1000) # setting column TM[,2] <- 1
data(images8By8) # Create tableMatrix from images8By8 TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) TM[2,1] <- "aaa" TM[1,"dimX"] <- 1000 # setting row TM[2,] <- list("aaa", 1000, 1000) # setting column TM[,2] <- 1
tableList
method, passes double bracket functionality to the table attribute.
## S3 method for class 'tableList' x[[...]]
## S3 method for class 'tableList' x[[...]]
x |
|
... |
Passed arguments. |
vector
S3 tableMatrix generic to get or set aid attribute
aid(obj, ...) aid(obj) <- value
aid(obj, ...) aid(obj) <- value
obj |
Object. |
... |
Passed arguments. |
value |
User defined |
User aid data.
tableList
method to get or set aid attribute.
## S3 method for class 'tableList' aid(obj, ...) ## S3 replacement method for class 'tableList' aid(obj) <- value
## S3 method for class 'tableList' aid(obj, ...) ## S3 replacement method for class 'tableList' aid(obj) <- value
obj |
|
... |
Passed arguments. |
value |
User defined. |
Aid part.
Column binding
Column binding of tab part of tableMatrix
or tableList
object.
## S3 method for class 'tableList' cbind(x, y, ...) ## S3 method for class 'tableMatrix' cbind(x, y, ...)
## S3 method for class 'tableList' cbind(x, y, ...) ## S3 method for class 'tableMatrix' cbind(x, y, ...)
x |
|
y |
|
... |
Passed arguments. |
Matrix object.
Copy of a tableList
object.
## S3 method for class 'tableList' copy(obj)
## S3 method for class 'tableList' copy(obj)
obj |
|
tableList
object.
Copy of a tableMatrix
object.
## S3 method for class 'tableMatrix' copy(obj)
## S3 method for class 'tableMatrix' copy(obj)
obj |
|
tableMatrix
object.
S3 tableMatrix generic to get or set dataType attribute
dataType(obj, ...) dataType(obj) <- value
dataType(obj, ...) dataType(obj) <- value
obj |
Object. |
... |
Passed arguments. |
value |
Named list. |
List.
tableList
and tableMarix
method to get or set dataType attribute.
## S3 method for class 'tableList' dataType(obj, ...) ## S3 replacement method for class 'tableList' dataType(obj) <- value ## S3 method for class 'tableMatrix' dataType(obj, ...) ## S3 replacement method for class 'tableMatrix' dataType(obj) <- value
## S3 method for class 'tableList' dataType(obj, ...) ## S3 replacement method for class 'tableList' dataType(obj) <- value ## S3 method for class 'tableMatrix' dataType(obj, ...) ## S3 replacement method for class 'tableMatrix' dataType(obj) <- value
obj |
|
... |
Passed arguments. |
value |
List of datatypes. |
List of datatypes.
tableList
method, returns dimensions of the table attribute.
## S3 method for class 'tableList' dim(x)
## S3 method for class 'tableList' dim(x)
x |
|
Dimensions of the table part.
tableList
method, returns dimension names of the table attribute.
## S3 method for class 'tableList' dimnames(x)
## S3 method for class 'tableList' dimnames(x)
x |
|
Column and row names of the table part.
S3 tableMatrix generic to get or set row from matrix attribute
getRow(...) setRow(...)
getRow(...) setRow(...)
... |
Passed arguments. |
numeric vector.
tableMatrix
method to get or set a row from the matrix attribute.
## S3 method for class 'tableMatrix' getRow(obj, i = NULL, repo = NULL, ...) ## S3 method for class 'tableMatrix' setRow(obj, value, i = NULL, repo = NULL, ...)
## S3 method for class 'tableMatrix' getRow(obj, i = NULL, repo = NULL, ...) ## S3 method for class 'tableMatrix' setRow(obj, value, i = NULL, repo = NULL, ...)
obj |
|
i |
Integer. Row index in |
repo |
Numeric vector. Vector with 2 elements - matN and matRow. |
... |
Passed arguments. |
value |
Vector for setting value. |
Row from the matrix part.
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) # Row 91 in tab(TM) corresponds to second matrix, first row row <- getRow(TM, 91) # Row 91 in tab(TM) corresponds to second matrix, first row getRow(TM, repo=c(2,1)) # Change matrix row corresponding to row 91 in tab(TM) TM <- setRow(TM, rep(2,length(row)), 91) getRow(TM, 91)
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) # Row 91 in tab(TM) corresponds to second matrix, first row row <- getRow(TM, 91) # Row 91 in tab(TM) corresponds to second matrix, first row getRow(TM, repo=c(2,1)) # Change matrix row corresponding to row 91 in tab(TM) TM <- setRow(TM, rep(2,length(row)), 91) getRow(TM, 91)
S3 tableMatrix generic to get row dim
getRowDim(...)
getRowDim(...)
... |
Passed arguments. |
integer vector.
tableMatrix
method to get row dimensions from matDim attribute.
## S3 method for class 'tableMatrix' getRowDim(obj, i = NULL, repo = NULL, ...)
## S3 method for class 'tableMatrix' getRowDim(obj, i = NULL, repo = NULL, ...)
obj |
|
i |
Integer. Row index in |
repo |
Numeric vector. Vector with 2 elements - matN and matRow. |
... |
Passed arguments. |
Dimensions corresponding to the row.
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(r=c(1,3), r=c(1,3)), list(r=c(4,ncol(images8By8)),r=c(4,ncol(images10By10))),list(c(8,8),c(10,10)), dimNames =c("dimX", "dimY")) matDim(TM) tab(TM) # Dimensions corresponding to row 1 in tab(TM) getRowDim(TM, 1) # Dimensions corresponding to row 91 in tab(TM) getRowDim(TM, 91) # Dimensions corresponding to row 1 in second matrix in mat(TM) getRowDim(TM, repo=c(2,1))
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(r=c(1,3), r=c(1,3)), list(r=c(4,ncol(images8By8)),r=c(4,ncol(images10By10))),list(c(8,8),c(10,10)), dimNames =c("dimX", "dimY")) matDim(TM) tab(TM) # Dimensions corresponding to row 1 in tab(TM) getRowDim(TM, 1) # Dimensions corresponding to row 91 in tab(TM) getRowDim(TM, 91) # Dimensions corresponding to row 1 in second matrix in mat(TM) getRowDim(TM, repo=c(2,1))
S3 tableMatrix generic to get row repo for matrix attribute
getRowRepo(...)
getRowRepo(...)
... |
Passed arguments. |
numeric vector.
tableMatrix
method to get row repo (vector of matN and matRow) for the matrix attribute
## S3 method for class 'tableMatrix' getRowRepo(obj, i = NULL, repo = NULL, ...)
## S3 method for class 'tableMatrix' getRowRepo(obj, i = NULL, repo = NULL, ...)
obj |
|
i |
Integer. Row index in |
repo |
Numeric vector. Vector with 2 elements - matN and matRow. |
... |
Passed arguments. |
Vector of matN and matRow.
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(c(4:ncol(images8By8)),c(4:ncol(images10By10)))) tab(TM) # Row 2 in tab(TM) corresponds to first matrix, second row getRowRepo(TM, 2) # Row 91 in tab(TM) corresponds to second matrix, first row getRowRepo(TM, 91)
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(c(4:ncol(images8By8)),c(4:ncol(images10By10)))) tab(TM) # Row 2 in tab(TM) corresponds to first matrix, second row getRowRepo(TM, 2) # Row 91 in tab(TM) corresponds to second matrix, first row getRowRepo(TM, 91)
Dataset containing samples of multivariate normal distributions. Each row in the dataset represents a generated matrix. Dimensions are stored in dimX and dimY columns. Directions "up" and "down" correspond to different covariance matrices. Direction "both" was created as a combination of "up" and "down".
images10By10
images10By10
Data frame with 90 rows and 103 variables:
direction direction of diagonal, factor "up", "down", "both"
dimX dimension x of image, in pixels
dimY dimension y of image, in pixels
pixel1:pixel100 pixel of image, in number
Dataset containing samples of multivariate normal distributions. Each row in the dataset represents a generated matrix. Dimensions are stored in dimX and dimY columns. Directions "up" and "down" correspond to different covariance matrices. Direction "both" was created as a combination of "up" and "down".
images8By8
images8By8
Data frame with 90 rows and 67 variables:
direction direction of diagonal, factor "up", "down", "both"
dimX dimension x of image, in pixels
dimY dimension y of image, in pixels
pixel1:pixel64 pixel of image, in number
Tests if passed object is of class tableList
is.tableList(obj)
is.tableList(obj)
obj |
|
logical vector.
Tests if passed object is of class tableMatrix
is.tableMatrix(obj)
is.tableMatrix(obj)
obj |
|
logical vector.
S3 tableMatrix generic to get or set matrix attribute
mat(obj, ...) mat(obj) <- value
mat(obj, ...) mat(obj) <- value
obj |
Object. |
... |
Passed arguments. |
value |
List of matrices. |
List of matrices
tableMatrix
method to get or set matrix part attribute. Matrix part is a
list of matrices.
## S3 method for class 'tableMatrix' mat(obj, matN = NULL, ...) ## S3 replacement method for class 'tableMatrix' mat(obj) <- value
## S3 method for class 'tableMatrix' mat(obj, matN = NULL, ...) ## S3 replacement method for class 'tableMatrix' mat(obj) <- value
obj |
|
matN |
Integer. Matrix number in the matrix part list. |
... |
Passed arguments. |
value |
List of matrices. |
Full matrix part of tableMatrix
or a matrix.
data(images8By8) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) # Full matrix part of TM mat(TM) # Matrix part of TM corresponding to matrix type 2 mat(TM, 2)
data(images8By8) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) # Full matrix part of TM mat(TM) # Matrix part of TM corresponding to matrix type 2 mat(TM, 2)
S3 tableMatrix generic to get or set matDim attribute
matDim(obj, ...) matDim(obj) <- value
matDim(obj, ...) matDim(obj) <- value
obj |
Object. |
... |
Passed arguments. |
value |
data.table |
data.table
tableMatrix
method to get or set matDim attribute.
## S3 method for class 'tableMatrix' matDim(obj, matN = NULL, resetN = FALSE, ...) ## S3 replacement method for class 'tableMatrix' matDim(obj) <- value
## S3 method for class 'tableMatrix' matDim(obj, matN = NULL, resetN = FALSE, ...) ## S3 replacement method for class 'tableMatrix' matDim(obj) <- value
obj |
|
matN |
Integer. Matrix number in the matrix part list. |
resetN |
Logical. When FALSE |
... |
Passed arguments. |
value |
data.table |
Full dimensions part of tableMatrix
or a subset of dimensions part.
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(r=c(4,ncol(images8By8)),r=c(4,ncol(images10By10)))) # Dimensions part of TM matDim(TM) # Dimensions part of TM corresponding to matrix type 2 matDim(TM, 2)
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(r=c(4,ncol(images8By8)),r=c(4,ncol(images10By10)))) # Dimensions part of TM matDim(TM) # Dimensions part of TM corresponding to matrix type 2 matDim(TM, 2)
Merging tableList
tableMatrix
method, merges tableMatrix
or tableList
objects with data.table,
data.frame, tableList
or tableMatrix
.
## S3 method for class 'tableList' merge(x, y, key, ...) ## S3 method for class 'tableMatrix' merge(x, y, key, ...)
## S3 method for class 'tableList' merge(x, y, key, ...) ## S3 method for class 'tableMatrix' merge(x, y, key, ...)
x |
|
y |
data.table, data.frame, |
key |
Shared columns as merging key. |
... |
Passed arguments. |
tableMatrix
object.
data(images8By8) # Create tableMatrix from images8By8 TM <- tableMatrix(images8By8, c("direction","dimX","dimY"), 4:ncol(images8By8), c(8,8)) # Merge tableMatrix object with a data.frame merge(TM, data.frame(direction="down", flag=TRUE), key="direction")
data(images8By8) # Create tableMatrix from images8By8 TM <- tableMatrix(images8By8, c("direction","dimX","dimY"), 4:ncol(images8By8), c(8,8)) # Merge tableMatrix object with a data.frame merge(TM, data.frame(direction="down", flag=TRUE), key="direction")
tableList
method, prints table attribute.
## S3 method for class 'tableList' print(x, ...)
## S3 method for class 'tableList' print(x, ...)
x |
|
... |
Passed arguments. |
tableMatrix
method, prints table attribute without tmName
columns.
## S3 method for class 'tableMatrix' print(x, ...)
## S3 method for class 'tableMatrix' print(x, ...)
x |
|
... |
Passed arguments. |
tableList
method, binds rows of tableList
objects.
## S3 method for class 'tableList' rbind(..., use.names = TRUE, fill = FALSE)
## S3 method for class 'tableList' rbind(..., use.names = TRUE, fill = FALSE)
... |
|
use.names |
Passed to rbind.data.table. |
fill |
Passed to rbind.data.table. |
tableList
object.
data(images8By8) data(images10By10) # Create tableList objects from images8By8[,1:3] and images10By10[,1:3] TL1 <- tableList(images8By8[,1:3]) TL2 <- tableList(images10By10[,1:3]) # Bindind rows of two tableList objects rbind(TL1, TL2)
data(images8By8) data(images10By10) # Create tableList objects from images8By8[,1:3] and images10By10[,1:3] TL1 <- tableList(images8By8[,1:3]) TL2 <- tableList(images10By10[,1:3]) # Bindind rows of two tableList objects rbind(TL1, TL2)
tableMatrix
method, binds rows of tableMatrix
objects. If
matrix parts have the same dimensions, it combines rows in table and matrix parts
using data.table and matrix rbind methods respectively. In case when dimensions differ
it combines rows in table part and adds new matrix to the matrix part.
## S3 method for class 'tableMatrix' rbind(..., use.names = TRUE, fill = FALSE)
## S3 method for class 'tableMatrix' rbind(..., use.names = TRUE, fill = FALSE)
... |
|
use.names |
Passed to rbind.data.table. |
fill |
Passed to rbind.data.table. |
tableMatrix
object.
data(images8By8) dim(images8By8) data(images10By10) dim(images10By10) # Create tableMatrix objects from images8By8 and images10By10 TM1 <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) TM2 <- tableMatrix(images10By10, 1:3, 4:ncol(images10By10)) # Combining tableMatrix objects with same dimensions TM <- rbind(TM1, TM1) # Combined table part tab(TM) # One matrix in the matrix part length(mat(TM)) # One dimension type matDim(TM) # Combining tableMatrix objects with different dimensions TM <- rbind(TM1, TM2) # Combined table part tab(TM) # Two matrices in the matrix part length(mat(TM)) # Two dimension types matDim(TM)
data(images8By8) dim(images8By8) data(images10By10) dim(images10By10) # Create tableMatrix objects from images8By8 and images10By10 TM1 <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) TM2 <- tableMatrix(images10By10, 1:3, 4:ncol(images10By10)) # Combining tableMatrix objects with same dimensions TM <- rbind(TM1, TM1) # Combined table part tab(TM) # One matrix in the matrix part length(mat(TM)) # One dimension type matDim(TM) # Combining tableMatrix objects with different dimensions TM <- rbind(TM1, TM2) # Combined table part tab(TM) # Two matrices in the matrix part length(mat(TM)) # Two dimension types matDim(TM)
S3 tableMatrix generic to get or set table attribute
tab(obj, ...) tab(obj) <- value
tab(obj, ...) tab(obj) <- value
obj |
Object. |
... |
Passed arguments. |
value |
data.table |
data.table
tableList
method to get or set table attribute.
## S3 method for class 'tableList' tab(obj, ...) ## S3 replacement method for class 'tableList' tab(obj) <- value
## S3 method for class 'tableList' tab(obj, ...) ## S3 replacement method for class 'tableList' tab(obj) <- value
obj |
|
... |
Passed arguments. |
value |
data.table |
Table part.
tableMatrix
method to get or set table attribute of tableMatrix
object.
## S3 method for class 'tableMatrix' tab(obj, matN = NULL, addRow = FALSE, resetN = TRUE, ...)
## S3 method for class 'tableMatrix' tab(obj, matN = NULL, addRow = FALSE, resetN = TRUE, ...)
obj |
|
matN |
Integer. Matrix number in |
addRow |
Logical. If TRUE column |
resetN |
Logical. Used when matN is specified. When FALSE
|
... |
Passed arguments. |
Full table part of tableMatrix
or a subset of table part.
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) matDim(TM) # Table part of TM tab(TM) # Table part of TM corresponding to matrix type 2 tab(TM, 2) # Add row indexes tab(TM, 2, TRUE)
data(images8By8) data(images10By10) # Create tableMatrix from images8By8 and images10By10 TM <- tableMatrix(list(images8By8, images10By10), list(1:3, 1:3), list(4:ncol(images8By8),4:ncol(images10By10))) matDim(TM) # Table part of TM tab(TM) # Table part of TM corresponding to matrix type 2 tab(TM, 2) # Add row indexes tab(TM, 2, TRUE)
tableList
constructor, creates tableList object from a data.frame or a data.table
and from aid data. The goal is to wrap data.table and any additional data structures together.
tableList
behaves like a data.table object. Groups of attributes can be stored together via
dataType
.
tableList(tabData, aidData = list(), dataType = NULL)
tableList(tabData, aidData = list(), dataType = NULL)
tabData |
A data.frame or a data.table. |
aidData |
Aid structures, generally in the form of a list. |
dataType |
Named list. Contains names of groups of attributes, elements are attributes which belong to the group. |
A tableList
object
dim.tableList
, dimnames.tableList
rbind.tableList
data(chickwts) # Bundle chickwts data.frame together with a linear model TL <- tableList(chickwts, lm(weight~feed, chickwts)) # tableList behaves like a data.table mean(TL[feed=="casein", weight]) # Aid part of the tableList object carries the linear model aid(TL) # dataType support TL <- tableList(chickwts, lm(weight~feed, chickwts), dataType=list(group1="weight", group2="feed"))
data(chickwts) # Bundle chickwts data.frame together with a linear model TL <- tableList(chickwts, lm(weight~feed, chickwts)) # tableList behaves like a data.table mean(TL[feed=="casein", weight]) # Aid part of the tableList object carries the linear model aid(TL) # dataType support TL <- tableList(chickwts, lm(weight~feed, chickwts), dataType=list(group1="weight", group2="feed"))
tableMatrix
constructor, creates tableMatrix object from a list of
data.frames or data.tables. It is useful for datasets with the following
structure: first set of columns of varying types is intended as meta data,
second set of columns of the same type is intended as main data.
tableMatrix
combines strengths of data.table (access via bracket
to the meta data part) and matrix (main data). It also stores dimensions of main data,
thus allowing to combine rows of varying lengths into one object. As in tableList
,
tableMatrix
can carry any additional aid data and data types groups.
tableMatrix(dataList, tabCol, matCol, dims = NULL, dimNames = NULL, aidData = list(), dataType = NULL)
tableMatrix(dataList, tabCol, matCol, dims = NULL, dimNames = NULL, aidData = list(), dataType = NULL)
dataList |
Dataset(s) in the form of data.frame or data.table or list of data.frames or data.tables. All datasets must have the same meta data columns, matrix parts can be different. |
tabCol |
Integer or character vector or list of these vectors. Specifies column
names or indices of meta data part. For list input, names |
matCol |
Integer or character vector or list of these vectors. Specifies column
names or indices of main data part. For list input, names |
dims |
Numeric vector or list of vectors. Specifies dimensions for the |
dimNames |
Character vector. Specifies dimension names in |
aidData |
Aid structures generally in the form of a list. |
dataType |
Named list. Contains names of groups of attributes, elements are attributes which belong to the group. |
tableMatrix
is a S3 class that consists of 4 parts.
tab
- table part - is used for storing meta data,
mat
- matrix part - for storing main data and matDim
- dimensions part - for
dimensions of main data.
mat
is a list of matrices. tab
is a data.table. In tab
first column tm.matN
is the matrix number in mat
, second column tm.matRow
is the row in the matrix.
matDim
is data.table
. In matDim
for each matrix number tm.matN
dimensions
can be specified with user defined dimensions. dataType
is a list which contains names of groups of
attributes and vectors of attributes belonging to it.
Default print of tableMatrix
is the print of the tab
part without tm.matN
and
tm.matRow
columns.
A tableMatrix
object
getRowRepo.tableMatrix
, getRowDim.tableMatrix
,
merge.tableMatrix
, rbind.tableMatrix
data(images8By8) dim(images8By8) data(images10By10) dim(images10By10) images10By10DT <- data.table::as.data.table(images10By10) # Generate tableMatrix from data.frame images8By8: use columns 1:3 as meta data and # columns 4:ncol(images8By8) as main data TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) matDim(TM) # show matDim tab(TM) # show meta data part of tableMatrix head(mat(TM)[[1]]) # show head of main data part # Generate tableMatrix from data.frame images8By8: use columns "direction" and "dimY" # as meta data and columns 4:ncol(images8By8) as main data tableMatrix(images8By8, c("direction","dimY"), 4:ncol(images8By8)) # User defined dimensions with default names TM <- tableMatrix(images8By8, c("direction","dimX","dimY"), 4:ncol(images8By8), c(8,8)) matDim(TM) # User defined dimensions with custom names dims <- c(8,8) names(dims) <- c("dimX", "dimY") TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8), dims) matDim(TM) # tabCol and matCol list input with "j" option # Column indices: first 3 columns in tab, rest in mat tableMatrix(images8By8, list(j=1:3), list(j=4:ncol(images8By8))) # Column names: columns "direction" and "dimY" in tab, # columns "pixel1" and "pixel2" in mat tableMatrix(images8By8, list(j=c("direction","dimY")), list(j=c("pixel1","pixel2"))) # tabCol and matCol list input with "r" option # Column indices: first 3 columns in tab, rest in mat tableMatrix(images8By8, list(r=c(1,3)), list(r=c(4,ncol(images8By8)))) # Same with column names tableMatrix(images8By8, list(r=c("direction","dimY")), list(r=c("pixel1","pixel100"))) # data.table as the start dataset tableMatrix(images10By10DT, 1:3, 4:ncol(images10By10DT)) # data.frame and data.table with different main data parts -> two matrices in mat. # Elements in tabCol and matCol lists correspond to images8By8 and images10By10DT # respectively TM <- tableMatrix(list(images8By8, images10By10DT), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(4:ncol(images8By8),4:ncol(images10By10DT))) matDim(TM) length(mat(TM)) # 2 matrices in mat # User defined named dimensions TM <- tableMatrix(list(images8By8, images10By10), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(c(4:ncol(images8By8)),c(4:ncol(images10By10))),list(c(8,8),c(10,10)), dimNames =c("dimX", "dimY")) matDim(TM) # Same main data parts -> only one matrix in mat TM <- tableMatrix(list(images8By8, images8By8), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(j=4:ncol(images8By8),4:ncol(images8By8))) matDim(TM) length(mat(TM)) # 1 matrix in mat # dataType support TM <- tableMatrix(images10By10, 1:3, 4:ncol(images10By10), dataType=list("group1"="direction", "group2"=c("dimX","dimY"))) dataType(TM)
data(images8By8) dim(images8By8) data(images10By10) dim(images10By10) images10By10DT <- data.table::as.data.table(images10By10) # Generate tableMatrix from data.frame images8By8: use columns 1:3 as meta data and # columns 4:ncol(images8By8) as main data TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8)) matDim(TM) # show matDim tab(TM) # show meta data part of tableMatrix head(mat(TM)[[1]]) # show head of main data part # Generate tableMatrix from data.frame images8By8: use columns "direction" and "dimY" # as meta data and columns 4:ncol(images8By8) as main data tableMatrix(images8By8, c("direction","dimY"), 4:ncol(images8By8)) # User defined dimensions with default names TM <- tableMatrix(images8By8, c("direction","dimX","dimY"), 4:ncol(images8By8), c(8,8)) matDim(TM) # User defined dimensions with custom names dims <- c(8,8) names(dims) <- c("dimX", "dimY") TM <- tableMatrix(images8By8, 1:3, 4:ncol(images8By8), dims) matDim(TM) # tabCol and matCol list input with "j" option # Column indices: first 3 columns in tab, rest in mat tableMatrix(images8By8, list(j=1:3), list(j=4:ncol(images8By8))) # Column names: columns "direction" and "dimY" in tab, # columns "pixel1" and "pixel2" in mat tableMatrix(images8By8, list(j=c("direction","dimY")), list(j=c("pixel1","pixel2"))) # tabCol and matCol list input with "r" option # Column indices: first 3 columns in tab, rest in mat tableMatrix(images8By8, list(r=c(1,3)), list(r=c(4,ncol(images8By8)))) # Same with column names tableMatrix(images8By8, list(r=c("direction","dimY")), list(r=c("pixel1","pixel100"))) # data.table as the start dataset tableMatrix(images10By10DT, 1:3, 4:ncol(images10By10DT)) # data.frame and data.table with different main data parts -> two matrices in mat. # Elements in tabCol and matCol lists correspond to images8By8 and images10By10DT # respectively TM <- tableMatrix(list(images8By8, images10By10DT), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(4:ncol(images8By8),4:ncol(images10By10DT))) matDim(TM) length(mat(TM)) # 2 matrices in mat # User defined named dimensions TM <- tableMatrix(list(images8By8, images10By10), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(c(4:ncol(images8By8)),c(4:ncol(images10By10))),list(c(8,8),c(10,10)), dimNames =c("dimX", "dimY")) matDim(TM) # Same main data parts -> only one matrix in mat TM <- tableMatrix(list(images8By8, images8By8), list(r=c("direction","dimY"), j=c("direction","dimX","dimY")), list(j=4:ncol(images8By8),4:ncol(images8By8))) matDim(TM) length(mat(TM)) # 1 matrix in mat # dataType support TM <- tableMatrix(images10By10, 1:3, 4:ncol(images10By10), dataType=list("group1"="direction", "group2"=c("dimX","dimY"))) dataType(TM)