File: lisrelMat2RAM.R

package info (click to toggle)
r-cran-semplot 1.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,351 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
modMat2Pars <- function(x,edge,exprname,symmetric=FALSE,vec=FALSE,cols,rows,group="",exprsup="")
{
  # Define x Pars:
  if (length(x)>0)
  {
    if (symmetric)
    {
      if (!isSymmetric(x$est)) stop(paste0("'",deparse(substitute(x)),"' matrix must be symmetrical."))
      x$est[upper.tri(x$est)] <- 0  
    }
    
    Pars <- data.frame(
      label = "", 
      lhs = rep(cols,each=length(rows)),
      edge = edge,
      rhs = rep(rows,times=length(cols)),
      est = c(x$est),
      std = NA,
      group = group,
      fixed = FALSE,
      par = 0,
      stringsAsFactors=FALSE)
    
    if (!vec)
    {
      Pars$label <- c(outer(1:nrow(x$est),1:ncol(x$est),function(x,y)paste0(exprname,"[",x,y,"]",exprsup)))
    } else {
      Pars$label <- paste0(exprname,"[",1:length(x$est),"]",exprsup)
    }
    if (!is.null(x[['std']]))
    {
      Pars[['std']] <- c(x[['std']])
    }
    if (!is.null(x[['par']]))
    {
      Pars[['par']] <- c(x[['par']])
    }
    if (!is.null(x[['fixed']]))
    {
      Pars[['fixed']] <- c(x[['fixed']])
    }
    
  } else Pars <- data.frame(
    label = character(0), 
    lhs = character(0),
    edge = character(0),
    rhs = character(0),
    est = numeric(0),
    std = numeric(0),
    group = character(0),
    fixed = logical(0),
    par = numeric(0),
    stringsAsFactors=FALSE)
  
  return(Pars)
}