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

timeseries of multi-basic

parent f76c4f33
#' basicr
#' basicr
#' @param df tbl_friendlyts data.frame
#' @param target target
#' @param group "none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND" or several
#' @param precision "daily","hourly","minute","second",...
#' @keywords basicr
#' @export
#' @examples
#' \dontrun{
#' basicr()
#' }
basic_ts <- function(df,target,group,precision){
basic <- basic_info(df=df,target=target,group=group)
varnames <- setdiff(names(basic),group)
varnames_ts <- c(friendlyts::get_name_date_col(precision=precision),"value",varnames)
res_ts <- as.data.frame(setnames(replicate(length(varnames_ts),rep(NA,nrow(df)), simplify = F), varnames_ts))
res_ts[,friendlyts::get_name_date_col(precision=precision)] <- as.data.frame(df)[,friendlyts::get_name_date_col(precision=precision)]
for (i in 1:nrow(basic)) {
tmp <- lapply(group,function(x){
res <- which(as.numeric(basic[i,x]) == as.numeric(res_ts[,x]))
return(res)
})
tmp <- table(unlist(tmp))
indice <- as.numeric(names(tmp[tmp==length(group)]))
res_ts[indice,"value"] <-df[i,target]
res_ts[indice,varnames] <-basic[i,varnames]
}
res <- friendlyts::friendlyts(df=res_ts,date_type="friendlyts",precision=precision)
class(res) <- c("basic_ts",class(res))
return(res)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/basic_ts.R
\name{basic_ts}
\alias{basic_ts}
\title{basicr
basicr}
\usage{
basic_ts(df, target, group, precision)
}
\arguments{
\item{df}{tbl_friendlyts data.frame}
\item{target}{target}
\item{group}{"none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND" or several}
\item{precision}{"daily","hourly","minute","second",...}
}
\description{
basicr
basicr
}
\examples{
\dontrun{
basicr()
}
}
\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