Commit 0379f0cc authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

replace basicr by basic_info to avoid any confusion

parent de8eff3d
#' basicr
#' basic_info
#' basicr
#' basic_info
#' @param df tbl_friendlyts data.frame
#' @param target target
#' @param group "none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"
#' @param group "none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND" or several
#' @keywords basicr
#' @export
#' @examples
#' \dontrun{
#' basicr()
#' basic_info()
#' }
basicr <- function(df,target,group="none"){
basic_info <- function(df,target,group="none"){
if (is.null(df) || (!inherits(df,"tbl_friendlyts")) ) {
stop("need non-null tbl_friendlyts df")
}
res <- switch(group,
"none" = df %>% basic_(target=target),
"YEAR" = df %>% group_by(YEAR) %>% basic_(target=target),
"MONTH" = df %>% group_by(MONTH) %>% basic_(target=target),
"WDAY" = df %>% group_by(WDAY) %>% basic_(target=target),
"HOUR" = df %>% group_by(HOUR) %>% basic_(target=target),
"MINUTE" = df %>% group_by(MINUTE) %>% basic_(target=target),
"SECOND" = df %>% group_by(SECOND) %>% basic_(target=target),
stop("group not recognized"))
if ( (length(group)>=1) && (prod(group %in% c("YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"))==1) && (sum(duplicated(group),na.rm=TRUE)==0) ){
class(res) <- class(res)[-which(class(res)=="tbl_friendlyts")]
res <- as_tbl_basic(res,group)
res <- df %>% group_by_(.dots=group) %>% basic_(target=target)
} else if ((length(group)==1) && (group =="none")) {
res <- df %>% basic_(target=target)
} else stop("group must refer to: 'none', 'YEAR', 'MONTH', 'WDAY', 'HOUR','MINUTE','SECOND'")
res <- tibble::as_tibble(res)
class(res) <- c(class(res),"tbl_basic")
return(res)
}
......@@ -50,11 +49,13 @@ basic_ <- function(df,target){
res <- df %>% summarise(
n = n(),
q0 = as.numeric(stats::quantile(targ,probs=0,na.rm=TRUE)),
q1 = as.numeric(stats::quantile(targ,probs=0.25,na.rm=TRUE)),
q2 = as.numeric(stats::quantile(targ,probs=0.50,na.rm=TRUE)),
q3 = as.numeric(stats::quantile(targ,probs=0.75,na.rm=TRUE)),
q4 = as.numeric(stats::quantile(targ,probs=1,na.rm=TRUE)),
q_0 = as.numeric(stats::quantile(targ,probs=0,na.rm=TRUE)),
q_0_05 = as.numeric(stats::quantile(targ,probs=0.05,na.rm=TRUE)),
q_0_25 = as.numeric(stats::quantile(targ,probs=0.25,na.rm=TRUE)),
q_0_5 = as.numeric(stats::quantile(targ,probs=0.50,na.rm=TRUE)),
q_0_75 = as.numeric(stats::quantile(targ,probs=0.75,na.rm=TRUE)),
q_0_95 = as.numeric(stats::quantile(targ,probs=0.95,na.rm=TRUE)),
q_1 = as.numeric(stats::quantile(targ,probs=1,na.rm=TRUE)),
IQR = as.numeric(stats::quantile(targ,probs=0.75,na.rm=TRUE)) - as.numeric(stats::quantile(targ,probs=0.25,na.rm=TRUE)),
m = mean(targ, na.rm = TRUE),
sd = stats::sd(targ, na.rm = TRUE),
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/basicr.R
\name{basicr}
\alias{basicr}
\title{basicr
basicr}
\name{basic_info}
\alias{basic_info}
\title{basic_info
basic_info}
\usage{
basicr(df, target, group = "none")
basic_info(df, target, group = "none")
}
\arguments{
\item{df}{tbl_friendlyts data.frame}
\item{target}{target}
\item{group}{"none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"}
\item{group}{"none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND" or several}
}
\description{
basicr
basicr
basic_info
basic_info
}
\examples{
\dontrun{
basicr()
basic_info()
}
}
\keyword{basicr}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment