join.columns: A function to collapse columns as strings.

Usage Arguments Examples

Usage

1

Arguments

obj

Examples

 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
##---- 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 (obj) 
{
    if (class(obj) == "list") {
        obj <- as.matrix(obj[[1]])
    }
    else {
        obj <- as.matrix(obj)
    }
    if (length(obj) == 0) {
        return(NULL)
    }
    else {
        if (ncol(as.matrix(obj)) >= 2) {
            n <- ncol(obj)
            out <- data.frame()
            sobj <- obj
            i <- 1
            for (i in 1:(n - 1)) {
                sobj[, i] <- paste(as.character(obj[, i]), as.character(obj[, 
                  i + 1]), sep = "|")
            }
            sobj[, -n]
        }
        else {
            obj
        }
    }
  }

dgrapov/devium documentation built on May 15, 2019, 7:21 a.m.