Learn R Programming

rgr (version 1.0.4)

var2fact: Rearranges Data for Variables as Factors

Description

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

Usage

var2fact(xmat)

Arguments

xmat
name of the n x m data matrix or dataframe to be processed.

Value

  • xxa n * m by 2 matrix where each of the n * m 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 dataframe are to be processed use the cbind construct. Thus, temp.mat <- cbind(varname1, varname3, varname6, varname8).

Examples

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

Run the code above in your browser using DataLab