Commit 29e59abc authored by Enrico Schumann's avatar Enrico Schumann

Initial commit

parents
*~
README.html
README.pdf
test_results.txt
2017-01-17 Enrico Schumann <es@enricoschumann.net>
* R/functions.R (read_ts_tables): new argument
'column.name' that specifies the pattern of column
names in results
2017-01-04 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): 0.3-1
* R/functions.R (read_ts_tables): if 'start' is
missing, use 1970-1-1 (instead of the previous
365 days)
2016-12-16 Enrico Schumann <es@enricoschumann.net>
* R/functions.R (read_ts_tables): fix naming of
series when 'return.class' is 'zoo'
2016-12-10 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): Version: 0.3-0
* R/functions.R (write_ts_table): new argument
'add'. If TRUE, only data for timestamps not in
a file is added.
2016-12-09 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): Version: 0.2-1
* R/functions.R (ts_table): store timestamp as
numeric; add new attribute 't.type' (either
Date or POSIXct)
(.timestamp): internal function
(`.timestamp<-`): internal function
2016-12-07 Enrico Schumann <es@enricoschumann.net>
* inst/Tutorial/README.org: move README to
inst/Tutorial
2016-12-05 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): Version: 0.2-0
* README.org: add file
* NAMESPACE: export only 'read_ts_tables',
'write_ts_table', 'ts_table', 'as.ts_table'
* R/functions.R (read_ts_tables): support
reading several columns from files
* R/functions.R (as.zoo.ts_table): export
method
* man/*: add help files for all functions
* inst/unitTests/ut_write_read.R
(test.ts_table): add unit tests
2016-12-01 Enrico Schumann <es@enricoschumann.net>
* man/read_ts_tables.Rd: add help file
2016-11-30 Enrico Schumann <es@enricoschumann.net>
* NAMESPACE: import datetimeutils::isBusinessDay
2016-11-25 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): Version: 0.1-1
* R/functions.R (as.ts_table): add function
(as.ts_table.zoo): add method
(as.zoo.ts_table): add method
2016-11-24 Enrico Schumann <es@enricoschumann.net>
* R/functions.R (ttime): add function
(write_ts_table): add function
(read_ts_tables): add function
(ts_table): add function
(as.data.frame.ts_table, print.ts_table): add
methods
Package: tsdb
Type: Package
Title: Terribly-Simple Data Base for Time Series
Version: 0.3-1
Date: 2017-01-04
Maintainer: Enrico Schumann <es@enricoschumann.net>
Authors@R: person("Enrico", "Schumann",
role = c("aut", "cre"),
email = "es@enricoschumann.net")
Description: A terribly-simple data base for time series. All
series are saved as csv files. The package offers utilities for
saving files in a standardised format, and for retrieving and
joining data.
License: GPL-3
Imports: datetimeutils, fastmatch, utils, zoo
export(
read_ts_tables,
write_ts_table,
ts_table,
as.ts_table
)
importFrom("datetimeutils",
"isBusinessDay",
"previousBusinessDay")
importFrom("fastmatch",
"fmatch")
importFrom("utils",
"read.table", "write.table")
importFrom("zoo",
"zoo", "coredata", "index", "as.zoo")
S3method(print, ts_table)
S3method(as.ts_table, zoo)
S3method(as.zoo, ts_table)
v0.4-0 (2017-02-06)
o 'read_ts_tables' has a new argument 'column.name',
which specifies the format of column names in results
v0.3-0 (2016-12-10)
o 'write_ts_table' has a new argument 'add': If TRUE,
only new data are added to a file, and existing
data are kept.
v0.2-1 (2016-12-09)
o A Tutorial is now installed with the package.
It can be accessed via
browseURL(system.file("Tutorial/README.html", package = "tsdb"))
browseURL(system.file("Tutorial/README.pdf", package = "tsdb"))
v0.2-0 (2016-12-05)
o 'read_ts_tables' can now read several columns
from files.
o New method 'as.zoo.ts_table' added.
o Tutorial added (see file README.org).
v0.1-0 (2016-11-24)
o Initial version of package.
This diff is collapsed.
This diff is collapsed.
pkg <- "tsdb"
if (tolower(Sys.getenv("ES_PACKAGE_TESTING")) == "true" &&
require("RUnit", quietly = TRUE) &&
require(pkg, quietly = TRUE, character.only = TRUE)) {
path <- paste0("~/Packages/", pkg, "/inst/unitTests")
## if the package is installed and you want to run
## the test, use this path:
##
## path <- system.file("unitTests", package = "PMwR")
##
myTestSuite <- defineTestSuite(pkg,
dirs = path,
testFileRegexp = "ut_.*")
stopifnot(isValidTestSuite(myTestSuite))
testResult <- runTestSuite(myTestSuite, verbose = 0L)
printTextProtocol(testResult,
showDetails = TRUE,
fileName = paste0(file.path(path, "test_results"), ".txt"))
}
## -*- truncate-lines: t; fill-column: 65; comment-column: 50; -*-
test.ts_table <- function() {
require("zoo")
x <- ts_table(11:15, as.Date("2016-1-1")-5:1, "close")
checkEquals(x,
structure(11:15,
.Dim = c(5L, 1L),
timestamp = c(16796, 16797, 16798, 16799, 16800),
t.type = "Date",
columns = "close",
class = "ts_table"))
tmp <- as.matrix(11:15); colnames(tmp) <- "close"
checkEquals(as.zoo(x),
zoo(tmp, as.Date("2016-1-1")-5:1))
checkEquals(as.ts_table(as.zoo(x)), x)
## intraday
y <- ts_table(11:15,
as.POSIXct("2016-1-1 10:00:00", tz = "UTC") + 0:4,
"close")
checkEquals(y,
structure(11:15, .Dim = c(5L, 1L),
timestamp = c(1451642400, 1451642401,
1451642402, 1451642403,
1451642404),
t.type = "POSIXct",
columns = "close",
class = "ts_table"))
}
test.read_ts_tables <- function() {
x <- ts_table(data = 11:15,
timestamp = as.Date("2016-1-1") + 1:5,
columns = "A")
y <- ts_table(cbind(1:5, 6:10),
as.Date("2016-1-1") + 1:5,
c("B", "A"))
dir <- tempdir()
write_ts_table(x, dir, "A")
write_ts_table(y, dir, "BA")
read_ts_tables("A", dir, columns = "A")
read_ts_tables("BA", dir, columns = "A")
tmp <- read_ts_tables(c("A", "BA"), dir, columns = c("A"),
start = "2016-1-1", drop.weekends = FALSE)
checkEquals(tmp[[1]],
structure(c(11, 12, 13, 14, 15, 6, 7, 8, 9, 10),
.Dim = c(5L, 2L)))
z1 <- ts_table(11:15, as.POSIXct("2016-1-1 10:00:00", tz = "UTC")+0:4, "close")
write_ts_table(z1, dir, "X1")
z2 <- ts_table(1:5, as.POSIXct("2016-1-1 10:00:00", tz = "UTC")+1:5, "close")
write_ts_table(z2, dir, "X2")
read_ts_tables(c("X1", "X2"), dir, columns = "close")
}
test.write_ts_table <- function() {
require(tsdb);require(RUnit)
dir <- tempdir()
x <- ts_table(data = 11:15,
timestamp = as.Date("2016-1-1") + 1:5,
columns = "A")
ans <- write_ts_table(x, dir, "A")
checkEquals(ans, nrow(x))
read_ts_tables("A", dir)
x <- ts_table(data = 11:16,
timestamp = as.Date("2016-1-1") + 1:6,
columns = "A")
write_ts_table(x, dir, "A", add = TRUE)
x <- ts_table(data = 1,
timestamp = as.Date("2015-1-1"),
columns = "A")
ans <- write_ts_table(x, dir, "A", add = TRUE)
checkEquals(ans, nrow(x))
x <- ts_table(data = 1,
timestamp = as.Date("2015-1-1"),
columns = "A")
write_ts_table(x, dir, "A")
}
\name{as.ts_table}
\alias{as.ts_table}
\alias{as.ts_table.zoo}
\title{
Coerce To ts_table
}
\description{
Coerce objects to \code{ts_table}
}
\usage{
as.ts_table(x, ...)
\method{as.ts_table}{zoo}(x, columns, \dots)
}
\arguments{
\item{x}{
object to be coerced to ts_table
}
\item{columns}{
character
}
\item{\dots}{
arguments to be passed to other methods
}
}
\details{
A generic function.
}
\value{
A ts_table.
}
\author{
Enrico Schumann
}
\seealso{
\code{\link{read_ts_tables}}
}
\examples{
require("zoo")
as.ts_table(zoo(1:5, Sys.Date()-5:1), ## note that the "columns"
columns = "value") ## must be specified
}
\name{read_ts_tables}
\alias{read_ts_tables}
\title{
Read Data from Files
}
\description{
Read time-series data from files.
}
\usage{
read_ts_tables(file, dir, t.type = "guess",
start, end, columns,
return.class = NULL,
drop.weekends = TRUE)
}
\arguments{
\item{file}{
character
}
\item{dir}{
character
}
\item{t.type}{
character: \code{guess}, \code{Date} or \code{POSIXct}
}
\item{start}{
character
}
\item{end}{
character
}
\item{columns}{
character. \bold{Currently only a single column is supported.}
}
\item{return.class}{
NULL or character
}
\item{drop.weekends}{
logical
}
}
\details{
Read files.
}
\value{
When return.class is \code{NULL}, a list:
\item{data}{a numeric matrix}
\item{timestamp}{Date or POSIXct}
\item{columns}{character}
\item{file.path}{character}
}
\author{
Enrico Schumann
}
\seealso{
write_ts_table
}
\examples{
\dontrun{
read_ts_tables(c("table1", "table2"), dir = "/tsdb",
columns = "close",
return.class = "zoo")}
}
\name{ts_table}
\alias{ts_table}
\title{
Create ts_table
}
\description{
Create \code{ts_table}
}
\usage{
ts_table(data, timestamp, columns)
}
\arguments{
\item{data}{
numeric
}
\item{timestamp}{
Date or POSIXct
}
\item{columns}{
column names
}
}
\details{
Creates a ts_table.
Timestamps must be of class Date or POSIXct (POSIXlt
is converted). A \code{tzone} attribute is dropped.
}
\value{
A \code{ts_table}:
}
\author{
Enrico Schumann
}
\seealso{
\code{\link{as.ts_table}}
}
\examples{
ts_table(1:5, Sys.Date()-5:1, columns = "value")
}
\name{tsdb-package}
\alias{tsdb-package}
\alias{tsdb}
\alias{ttime}
\title{
Store and Retrieve Time-Series
}
\description{
Several simple utilities that allow to handle
time-series data as CSV files.
}
\usage{
ttime(x, from = "datetime", to = "numeric", tz = "",
strip.attr = FALSE, format = "\%Y-\%m-\%d")
}
\arguments{
\item{x}{
numeric
}
\item{from}{
character
}
\item{to}{
character
}
\item{tz}{
character
}
\item{strip.attr}{
logical
}
\item{format}{
character
}
}
\details{
\code{ttime} (`translate time') converts timestamps
between formats.
}
\author{
Enrico Schumann
}
\seealso{
\code{\link{read_ts_tables}}
}
\examples{
## see the particular functions
}
\name{write_ts_table}
\alias{write_ts_table}
\title{
Write Data to Files
}
\description{
Write time-series data to files.
}
\usage{
write_ts_table(x, dir, file, add = FALSE, overwrite = FALSE)
}
\arguments{
\item{x}{
numeric data
}
\item{dir}{
character
}
\item{file}{
character
}
\item{add}{
logical: if TRUE, add data with timestamps that are
not in a file.
}
\item{overwrite}{
logical: overwrite existing file when data differs
}
}
\details{
Write files.
}
\value{
The number of data rows written to a file.
}
\author{
Enrico Schumann
}
\seealso{
write_ts_table
}
\examples{
\dontrun{
write_ts_table(ts_table(1, Sys.Date(), "a_column"),
dir = "~/tsdb/daily", file = "example")
}
}
\ No newline at end of file
%% \VignetteIndexEntry{Overview of the tsdb package}
\documentclass[a4paper,11pt]{article}
\usepackage[left = 3cm, top = 2cm, bottom = 2cm, right = 4cm]{geometry}
\usepackage[noae,nogin]{Sweave}
\usepackage{libertine}
\usepackage[scaled=0.8]{DejaVuSansMono}
\usepackage[T1]{fontenc}
\renewcommand*\familydefault{\sfdefault}
\usepackage{amsmath,amstext}
\usepackage{hyperref}
\usepackage{natbib}
\usepackage{xcolor}
\usepackage{framed}
\usepackage[hang]{footmisc}
\definecolor{grau2}{rgb}{.2,.2,.2}
\definecolor{grau7}{rgb}{.7,.7,.7}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{frame=single,
xleftmargin=0em, formatcom=\color{grau2},rulecolor=\color{grau7}}
\DefineVerbatimEnvironment{Scode}{Verbatim}{xleftmargin=2em}
\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
\SweaveOpts{keep.source = TRUE, eps = TRUE}
<<echo=false>>=
options(continue = " ", digits = 3, width = 60, useFancyQuotes = FALSE)
@
\begin{document}
\title{An Overview of the tsdb Package}
\author{Enrico Schumann\\\url{es@enricoschumann.net}}
{\raggedright{\LARGE An Overview of the \texttt{tsdb} Package}}\medskip
\noindent Enrico Schumann\\
\noindent \url{es@enricoschumann.net}\\
\bigskip
<<echo=false>>=
require("tsdb")
require("zoo")
@
See \texttt{README.org}.
\end{document}
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