Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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).

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.

Note

The p variables for n cases results in a n * p by 2 matrix, where [1:n, 1] contains the variable name for value[1] and [1:n, 2] contains the values for the n rows in the first column of xmat. Then rows [n+1:2n, 1] contain the variable name for value[2] and [n+1:2n, 2] contain the values for n rows in the second column, and so on.

Author(s)

Robert G. Garrett

Examples

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

## Clean-up
rm(temp)

rgr

Applied Geochemistry EDA

v1.1.15
GPL-2
Authors
Robert G. Garrett
Initial release
2018-03-05

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.