tFrame: Transpose a data frame

Description Usage Arguments Details Value Warning Author(s) See Also Examples

Description

Transposes a data frame, converting variables to cases and vice versa

Usage

1
tFrame(x)

Arguments

x

The data frame to be transposed.

Details

The tFrame function is a convenience function that simply transposes the input data frame and coerces the result back to a data frame. Apart from a very small amount of exception handling, it is equivalent to as.data.frame(t(x)). It exists simply because I sometimes find it convenient when teaching statistics to discuss simple data handling before going into details regarding coercion; similarly, since I generally have students work with data frames before exposing them to matrices, it is convenient to have a transpose function that returns a data frame as output.

Naturally, the tFrame function should only be used when it is actually sensible to think of the cases of x as variables in their own right. In real life I expect that this maps almost perfectly onto those cases where x could be a matrix just as easily as a data frame, so I don't believe that tFrame is useful in real world data analysis. It is intended as a teaching tool.

Value

The transposed data frame

Warning

This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.

Author(s)

Daniel Navarro

See Also

t

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create a data frame that could sensibly be transposed...	
Gf <- c(105, 119, 121, 98)   # fluid intelligence for 4 people
Gc <- c(110, 115, 119, 103)  # crystallised intelligence 
Gs <- c(112, 102, 108, 99)   # speed of processing
dataset <- data.frame( Gf, Gc, Gs ) 
rownames(dataset) <- paste( "person", 1:4, sep="" )
print(dataset)	

# Now transpose it...
tFrame( dataset )
	 	
	

svannoy/lsr-package documentation built on May 30, 2019, 8:45 p.m.