dist-access {tileHMM} | R Documentation |
These methods provide convenient access to objects of class dist
as well as
conversion to other data structures.
## S3 method for class 'discDist': as.data.frame(x, row.names = NULL, optional = FALSE, ...) ## S3 method for class 'discDist': as.vector(x, mode = "any") ## S3 method for class 'discDist': as.matrix(x, ...) ## S4 method for signature 'discDist': length(x) ## S3 method for class 'discDist': x[i, ...] ## S3 method for class 'discDist': x[[i, ...]] ## S3 method for class 'contDist': x[i, j, ...] ## S3 method for class 'tDist': x[i, j, log=FALSE, ...] ## S3 method for class 'contDist': x[i, j] <- value ## S3 method for class 'tDist': x[i, j] <- value
x |
Object of class discDist , contDist or tDist . |
i |
If x is an object of class discDist this is expected to be
a symbol from the alphabet of x . For all other classes i is interpreted
as the index of the mixture component that should be accessed. i may be missing
in which case values for all mixture components are returned or replaced. |
j |
Either a character string identifying one of the parameters of x or a numeric value.
In the later case the density at point j is returned. |
log |
Logical indicating whether the density value should be log transformed. |
row.names |
NULL or a character vector giving the row names for the data frame. Missing values are not allowed. |
optional |
logical. If TRUE, setting row names and converting column names (to syntactic names) is optional. |
mode |
Mode of vector . |
value |
New parameter value(s). |
... |
Additional arguments. |
The conversion functions return objects of the respective class.
length
returns the number of symbols in the alphabet of x
.
The access functions return either the requested parameter value or the value of the dansity
function at point j
.
Peter Humburg
## converting "discDist" objects nucleo <- new("discDist",alpha=c("A","C","G","T"),prob=rep(0.25,times=4)) nucleo.vec <- as.vector(nucleo) nucleo.mat <- as.matrix(nucleo) nucleo.df <- as.data.frame(nucleo) ## get number of symbols in alphabet len <- length(nucleo) # = 4 ## get probability for symbol 'A' nucleo['A'] # = 0.25 ## accessing tDist objects mydt <- new("tDist", mean=0, var=1, df=3) ## evaluate density function mydt[, 2] # = 0.06750966 mydt[, 1000] # = 3.307954e-12 mydt[, 1000, log=TRUE] # = -26.43469 ## access parameter values mydt[, "mean"] # = 0