setBlocks            package:dynamicGraph            R Documentation

_C_l_a_s_s "_d_g._B_l_o_c_k_L_i_s_t": _T_h_e _b_l_o_c_k _l_i_s_t

_D_e_s_c_r_i_p_t_i_o_n:

     Create a block list with positioning the vertices in the blocks.         

     Objects can be created by calls of the form 'new("dg.BlockList",
     ...)'.

_U_s_a_g_e:

     setBlocks(block.list, vertices, labels = NULL, 
               right.to.left = FALSE, nested.blocks = FALSE,
               blockColors = NULL, color = "Grey", N = 3)

_A_r_g_u_m_e_n_t_s:

block.list: The list of vectors identifying the 'blocks'. Each item in
          the list is a vector with of the indices (or text strings for
          names) of vertices of a block.  

vertices: The list of 'vertices', each containing the class
          'dg.Vertex'. Returned with positions set in the interval of
          the blocks. 

  labels: List of text strings with the 'labels' of the blocks. If
          'labels' is set to 'NULL' then labels are found as
          'names(block.list)'. 

right.to.left: Logical. If 'right.to.left' is set to TRUE then the
          explanatory blocks are drawn to the right. 

nested.blocks: Logical. If 'nested.blocks' then the blocks are drawn
          nested. 

blockColors: Vector of text string with the 'blockColors' of the
          blocks. 

   color: Single text string with 'color' of the blocks. Only used when
          'blockColors' is not given. 

       N: Integer, 'N' is the number of coordinates of the vertices and
          block corners. 

_V_a_l_u_e:

     A list with components 

  Blocks: The list of blocks, each of class  'dg.Block'.

Vertices: The list of vertices, with the positions of the vertices
          updated such the vertices has positions within the blocks. 

_S_l_o_t_s:

     '._D_a_t_a': Object of class '"list"'. 

_E_x_t_e_n_d_s:

     Class '"dg.NodeList"', directly. Class '"dg.list"', directly.
     Class '"list"', from data part. Class '"vector"', by class
     '"dg.NodeList"'. Class '"vector"', by class '"dg.list"'. Class
     '"vector"', by class '"list"'.

_M_e_t_h_o_d_s:

     _c_h_e_c_k_B_l_o_c_k_L_i_s_t 'signature(blockList = "dg.BlockList")': ... 

     _a_n_c_e_s_t_o_r_s_B_l_o_c_k_L_i_s_t 'signature(blockList = "dg.BlockList")': ... 

     _d_e_s_c_e_n_d_a_n_t_s_B_l_o_c_k_L_i_s_t 'signature(blockList = "dg.BlockList")': ... 

_A_u_t_h_o_r(_s):

     Jens Henrik Badsberg

_E_x_a_m_p_l_e_s:

     require(tcltk)

     require(dynamicGraph)

     V.Types <- c("Discrete", "Ordinal", "Discrete",
                  "Continuous", "Discrete", "Continuous")

     V.Names <- c("Sex", "Age", "Eye", "FEV", "Hair", "Shosize")
     V.Names <- paste(V.Names, 1:6, sep ="/")

     From <- c(1, 2, 3, 4, 5, 6)
     To   <- c(2, 3, 4, 5, 6, 1)

     # A block recursive model:

     Blocks <- list(Basic = c(2, 1), Intermediate = c(5, 4, 3),  Now = c(6))

     V.Names <- paste(V.Names, c(1, 1, 2, 2, 2, 3), sep =":")

     graph <- new("dg.simple.graph", vertex.names = V.Names, types = V.Types,
                  from = From, to = To, blocks = Blocks)

     W <- dg(graph,
             control = dg.control(width = 600, height = 600, drawblocks = TRUE,
                                  drawBlockBackground = FALSE, title = "DrawBlocks", 
                                  namesOnEdges = FALSE))

     # A block recursiv model, without drawing blocks:

     W <- dg(simpleGraphToGraph(graph, control = dg.control(drawblocks = FALSE)),
             control = dg.control(width = 600, height = 600, title = "No blocks drawn"))

     # A block recursive model with nested blocks:

     W <- dg(simpleGraphToGraph(graph, 
               control = dg.control(nested.blocks = TRUE,
                                    blockColors = 
                                    paste("Grey", 100 - 2 * (1:10), sep = ""))),
             control = dg.control(width = 600, height = 600, title = "Nested blocks"))

     # The block list of the last example:

     vertices <- returnVertexList(V.Names, types = V.Types)
     blockList <- setBlocks(Blocks, vertices = vertices,  nested.blocks = TRUE,
                            blockColors = paste("Grey", 100 - 2 * (1:10), sep = ""))

     names(blockList)
     str(blockList$Blocks[[1]])

     names(blockList$Blocks)
     Names(blockList$Blocks)
     Labels(blockList$Blocks)
     LabelPositions(blockList$Blocks)
     Positions(blockList$Blocks)
     Strata(blockList$Blocks)
     Colors(blockList$Blocks)
     NodeAncestors(blockList$Blocks)
     NodeDescendants(blockList$Blocks)
     Visible(blockList$Blocks)
     Indices(blockList$Blocks)

     names(blockList$Vertices)
     Names(blockList$Vertices)
     Labels(blockList$Vertices)
     LabelPositions(blockList$Vertices)
     Positions(blockList$Vertices)
     Strata(blockList$Vertices)
     Colors(blockList$Vertices)
     Indices(blockList$Vertices)

     asDataFrame(blockList$Vertices)
     asDataFrame(blockList$Blocks)

