long2mat:

Usage Arguments Examples

Usage

1
long2mat(x, Sid.col, dep.col)

Arguments

x
Sid.col
dep.col

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, Sid.col, dep.col) 
{
    if (length(dep.col) != 1) 
        stop("Argument dep.col must have a single value")
    if (is.null(dim(x))) 
        stop("x must be a matrix or data frame")
    Sid = unique(x[, Sid.col])
    n = nrow(x)
    nid = length(Sid)
    flag = (x[, Sid.col] == Sid[1])
    num.out = sum(flag)
    res = matrix(NA, nrow = nid, ncol = num.out)
    for (i in 1:nid) {
        flag = (x[, Sid.col] == Sid[i])
        res[i, ] = x[flag, dep.col]
    }
    res
  }

musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.