Rotating Data Tables / Matrices in R
* One can do a rotation operation over a T table / dataframe /
matrix object so that the rows become the columns and the columns become the
rows .
* For doing the rotation operation over any data table object /
data frame object or a matrix object in R , one can use the t() command .
* One can think of such a program as short for transpose
operation
* The given example begins with a dataframe that contains two
columns of numeric data with its rows also named .
* The final object is transposed ( means - the rows are changed to columns and the columns are changed to rows / reversal of attributes )
* Also , the new object is in fact a matrix rather than a
dataframe .
* One can see this much more clearly if one tries the same t() command over a simple vector .
* Vectors are treated like columns , but when they are displayed they look like rows
* In any event , when you apply a t() command one would get a matrix object as a result .
* One can easily convert the objects to a dataframe using the "as.dataframe()" command .
No comments:
Post a Comment