convertClass {gRapHD}R Documentation

Convert object between classes

Description

Convert objects between gRapHD and graphNEL classes.

Usage

  convertClass(object)

Arguments

object an object of gRapHD or graphNEL class.

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.

Value

An object with the opposite class to the input object.

Author(s)

Gabriel Coelho Goncalves de Abreu (Gabriel.Abreu@agrsci.dk)
Rodrigo Labouriau (Rodrigo.Labouriau@agrsci.dk)
David Edwards (David.Edwards@agrsci.dk)

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

  # convertion from gRapHD to graphNEL
  edges <- matrix(c(1,2,1,3,1,4),,2,byrow=TRUE)
  g <- as.gRapHD(edges)
  #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 <- convertClass(g)
  # A graphNEL graph with undirected edges
  # Number of Nodes = 4
  # Number of Edges = 3
  g1@nodes # the nodes names

[Package gRapHD version 0.1.0 Index]