Learn R Programming

rgr (version 1.1.15)

var2fact: Rearranges Data for Variables as Factors

Description

Rearranges data from a matrix or data frame into a matrix where data are tagged by their variables names as factors. Used to concatenate data for display with functions tbplots.by.var and bwplots.by.var.

Usage

var2fact(xmat)

Arguments

xmat

name of the n by p data matrix or data frame to be processed.

Value

xx

a n * p by 2 matrix where each of the n * p rows contains a value that is paired with its variable name as a factor, see Note below.

Details

If the data for only some of the variables available in an attached matrix or data frame are to be processed use the cbind construct. Thus, temp.mat <- cbind(vname1, vname3, vname6, vname8).

Examples

Run this code
# NOT RUN {
## Display, convert data frame and display the result
data(ms.data1)
ms.data1
temp <- var2fact(ms.data1)
temp

## Clean-up
rm(temp)
# }

Run the code above in your browser using DataLab