R/knit_str.R

Defines functions knit_str

Documented in knit_str

#' knit_str
#'
#' knitr::kable(str(robj)) 
#'
#' @return knits the output of str
#'
#' @author Tyler W Bradshaw, \email{tyler.w.bradshaw@duke.edu}
#'
#' @references [StackOverflow](https://stackoverflow.com/questions/44200394)
#'
#' @export
#'
#' @import knitr

knit_str <- function(robj,...){
	require(knitr)
	df <- data.frame(variable = names(robj),
		 class = sapply(robj, typeof),
		 first_values = sapply(robj, function(x) paste0(head(x),  collapse = ", ")),
		 row.names = NULL)
	knitr::kable(df,...)
}
twesleyb/miscR documentation built on July 8, 2021, 6:21 p.m.