-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dgrtwo
committed
Feb 17, 2015
1 parent
6ac6356
commit f1e35cf
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' Tidiers for matrix objects | ||
#' | ||
#' These perform tidying operations on matrix objects. \code{tidy} turns the | ||
#' matrix into a data.frame while bringing rownames, if they exist, in as | ||
#' a column called \code{.rownames} (since results of tidying operations never | ||
#' contain rownames). \code{glance} simply reports the number of rows and | ||
#' columns. Note that no augment method exists for matrices. | ||
#' | ||
#' @param x A matrix | ||
#' @param ... extra arguments, not used | ||
#' | ||
#' @examples | ||
#' | ||
#' mat <- as.matrix(mtcars) | ||
#' tidy(mat) | ||
#' glance(mat) | ||
#' | ||
#' @name matrix_tidiers | ||
|
||
|
||
#' @rdname matrix_tidiers | ||
#' | ||
#' @return \code{tidy.matrix} returns the original matrix converted into | ||
#' a data.frame, except that it incorporates rownames (if they exist) | ||
#' into a column called \code{.rownames}. | ||
#' | ||
#' @export | ||
tidy.matrix <- function(x, ...) { | ||
fix_data_frame(x, newcol = ".rownames") | ||
} | ||
|
||
|
||
#' @rdname matrix_tidiers | ||
#' | ||
#' @return \code{glance} returns a one-row data.frame with | ||
#' \item{nrow}{number of rows} | ||
#' \item{ncol}{number of columns} | ||
#' \item{complete.obs}{number of rows that have no missing values} | ||
#' \item{na.fraction}{fraction of values across all rows and columns that | ||
#' are missing} | ||
#' | ||
#' @export | ||
glance.matrix <- function(x, ...) { | ||
glance.data.frame(x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
% Generated by roxygen2 (4.1.0): do not edit by hand | ||
% Please edit documentation in R/matrix_tidiers.R | ||
\name{matrix_tidiers} | ||
\alias{glance.matrix} | ||
\alias{matrix_tidiers} | ||
\alias{tidy.matrix} | ||
\title{Tidiers for matrix objects} | ||
\usage{ | ||
\method{tidy}{matrix}(x, ...) | ||
|
||
\method{glance}{matrix}(x, ...) | ||
} | ||
\arguments{ | ||
\item{x}{A matrix} | ||
|
||
\item{...}{extra arguments, not used} | ||
} | ||
\value{ | ||
\code{tidy.matrix} returns the original matrix converted into | ||
a data.frame, except that it incorporates rownames (if they exist) | ||
into a column called \code{.rownames}. | ||
|
||
\code{glance} returns a one-row data.frame with | ||
\item{nrow}{number of rows} | ||
\item{ncol}{number of columns} | ||
\item{complete.obs}{number of rows that have no missing values} | ||
\item{na.fraction}{fraction of values across all rows and columns that | ||
are missing} | ||
} | ||
\description{ | ||
These perform tidying operations on matrix objects. \code{tidy} turns the | ||
matrix into a data.frame while bringing rownames, if they exist, in as | ||
a column called \code{.rownames} (since results of tidying operations never | ||
contain rownames). \code{glance} simply reports the number of rows and | ||
columns. Note that no augment method exists for matrices. | ||
} | ||
\examples{ | ||
mat <- as.matrix(mtcars) | ||
tidy(mat) | ||
glance(mat) | ||
} | ||
|