Learn R Programming

gRapHD (version 0.2.5)

gRapHD-class: Class "gRapHD"

Description

S4 class.

Arguments

Objects from the Class

Objects can be created, for example, by new("gRapHD", ...). Where ... may contain the initial attribute names and values, as described in the Slots section.

Slots

edges:

integer, matrix with 2 columns, each row representing one edges and each column one of the vertices in the edge. Column 1 containsthe vertex with lower index.

homog:

logical, TRUE if the covariance is homogeneous.

minForest:

integer, first and last edges found with minForest.

numCat:

integer, vector with number of levels for each variable (0 if continuous).

numP:

integer, vector with number of estimated parameters for each edge.

p:

integer, number of variables (vertices) in the model.

stat.minForest:

character, measure used (LR, AIC, or BIC).

stat.stepw:

character, measure used (LR, AIC, or BIC).

stat.user:

character, user defined.

statSeq:

numeric, vector with value of stat.minForest for each edge.

stepw:

interger, first and last edges found with stepw.

userDef:

integer, first and last edges defined by the user.

vertNames:

character, vector with vertices' names.

Methods

setMethod("initialize","gRapHD",initialize.gRapHD)

setMethod("summary",signature(object="gRapHD"),summary.gRapHD)

setMethod("print",signature(x="gRapHD"),print.gRapHD)

setMethod("show",signature(object="gRapHD"),show.gRapHD)

setMethod("plot",signature(x="gRapHD"),plot.gRapHD)

setAs(from="matrix",to="gRapHD",def=matrix.gRapHD)

setAs(from="gRapHD",to="graphNEL",def=gRapHD.graphNEL)

setAs(from="graphNEL",to="gRapHD",def=graphNEL.gRapHD)

Details

As the gRapHD class does not use variables names, but only the column indexes in the dataset, the conversion may change the variables references. When converting a gRapHD object to a graphNEL object, the nodes names in the new object are only the original indexes converted to character. When doing the reverse conversion, the nodes indexes in the new gRapHD object are the respective indexes in the original element nodes in the graphNEL object. See the example below.

References

R. Gentleman, Elizabeth Whalen, W. Huber and S. Falcon. graph: A package to handle graph data structures. R package version 1.22.2.

Examples

Run this code
# NOT RUN {
# convertion from gRapHD to graphNEL
edges <- matrix(c(1,2,1,3,1,4),,2,byrow=TRUE)
g <- as(edges,"gRapHD")
#List of 9
# $ edges    : num [1:3, 1:2] 1 1 1 2 3 4
# $ p        : int 4
# $ stat.user: chr "LR"
# $ statSeq  : num [1:3] NA NA NA
# $ varType  : int [1:4] 0 0 0 0
# $ numCat   : int [1:4] 0 0 0 0
# $ homog    : logi TRUE
# $ numP     : num [1:3] NA NA NA
# $ userDef  : num [1:2] 1 3
# - attr(*, "class")= chr "gRapHD"
g1 <- as(g,"graphNEL")
# A graphNEL graph with undirected edges
# Number of Nodes = 4
# Number of Edges = 3
g1@nodes # the nodes names


as(matrix(integer(0),,2),"gRapHD")
# note that the vertices must be numbered consecutively from 1. In the
# following, vertex 2 is added as an isolated vertex.
m1 <- as(matrix(c(1,3,1,4),,2,byrow=TRUE),"gRapHD")
# }
# NOT RUN {
plot(m1)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab