TimeData

Access metadata

idx(td::AbstractTimedata)

Get time index as array.

names(td::AbstractTimedata)

Get column names.

idxtype(td::AbstractTimedata)

Get type of idx.

Access data as Array

get(td::AbstractTimedata, idx1::Int, idx2::Int)

Get single entry [idx1, idx2] of TimeData object.

get(td::AbstractTimedata)

Get all entries of TimeData object as Array through comprehension.

core(td::AbstractTimedata)

Equal to get except for Timematr.

core(tm::Timematr)

Return data as Array{Float64}.

getAs(tn::AbstractTimedata, typ::Type=Any, replaceNA=NA)

Get all entries as Array. In order to avoid Array{Any, 2} as outcome, the entries can be promoted to a given Type through argument typ. Missing values can be dealt with through a third argument replaceNA, which replaces occurring NAs. For example, Timenum tm can be transformed to Array{Float64, 2} through: getAs(tm, Float64, NaN).

Access data as DataFrame

convert(::DataFrame, td::AbstractTimedata)

Convert Timedata object to DataFrame by prepending index column as column :idx.

Dealing with NAs

complete_cases(td::AbstractTimedata)

Return Array{Bool} with true for rows without NA values.

narm(td::AbstractTimedata)

Get complete cases: return copy of td with all rows removed that were containing NA.

rmDatesOnlyNAs(tn::AbstractTimedata)

Remove all dates that contain strictly missing values NA. Required format, for example, for plotting with Gadfly.

Show entries

Accessing entries through getindex methods will always preserve a rectangular table data structure: the output is an intersection of a subset of indices with a subset of columns. In contrast, showEntries methods allow to access data without rectangular structure as stacked data. This way, for example, entry (1,2) and entry (2,1) could be jointly accessed, without simultaneously returning entries (1,1) and (2,2). The output of showEntries always is of type Timedata, with columns variable and value.

showEntries(td::AbstractTimedata, f::Function; sort="dates")

Show all entries where function f returns true. By default, return values in row major order: for each date try all variables. Column major order can be achieved through sort="variables".

showEntries(td::AbstractTimedata, singleInd::Array{Int})

Show entries given by linear indexing.

showEntries(td::AbstractTimedata, rowInds::Array{Int}, colInds::Array{Int})

Show entries given by subscript indexing.

showEntries(td::AbstractTimedata, td2::AbstractTimedata)

Show entries by element-wise logical indexing.

Editing entries

setNA!(td::AbstractTimedata, rowIdx::Int, colIdx::Int)

Set a given entry to NA. Could require change of column type to DataArray. Throws error for Timematr.

setindex!(td::Timedata, value::Any, rowIdx::Int, colIdx::Int)

Set entry given by subscript indexing to a given value.

setindex!(td::AbstractTimenum, value::Any, rowIdx::Int, colIdx::Int)

Set entry given by subscript indexing to a given value.

impute!(td::AbstractTimedata, with="last")

Replace NA with some value. Implemented options are last to use the last available observation, next to use the next available option, zero to insert a value of 0 for each NA. single last only uses the last observation if there is a single NA in succession. For two or more successive values of NA no imputation occurs. A single NA in the last row will be treated as if observations would follow, so that it gets replaced. Consecutive occurrences of NA at the beginning of the sample will be left untouched with options last and single last. Same holds for consecutive occurrences of NA at the end of the sample for option next.

Basic functions

size(tn::AbstractTimedata)
size(tn::AbstractTimedata, ind::Int)
ndims(tn::AbstractTimedata)

Testing object properties

isequal(tn::AbstractTimedata, tn2::AbstractTimedata)

Test for equal indices, names, types and values. NA is equal to NA. Output is a single value of type Bool.

isequalElw(tn::AbstractTimedata, tn2::AbstractTimedata)

Element-wise comparison with isequal. Returns Timedata with boolean values.

==(tn::AbstractTimedata, tn2::AbstractTimedata)

Test for equal indices, names, types and values. NA is not counted as equal to NA. Output is a single value of type Bool.

.==(tn::AbstractTimedata, tn2::AbstractTimedata)

Element-wise test for equal values: NA is not counted as equal to NA. Returns Timedata with boolean values, or error if meta-data is not matching.

isapprox(tn::AbstractTimedata, tn2::AbstractTimedata)

Test for equal indices, names, types and approximately equal values. Alleviates unit tests for values of type Float. Output is a single value of type Bool.

equMeta(td1::AbstractTimedata, td2::AbstractTimedata)

Test for equal meta-data: type, column names and indices. Output is a single value of type Bool.

equColMeta(td1::AbstractTimedata, td2::AbstractTimedata)

Test for equal meta-data of columns (dates are left unconsidered): type and column names. Output is a single value of type Bool.

isnaElw(td::AbstractTimedata)

Element-wise testing for NA. Returns boolean values as Timedata object.

Date formatting functions

datesAsStrings(dats::Array{Date, 1})

Convert vector of dates into Array{ASCIIString, n}.

datesAsStrings(tm::AbstractTimedata)

Take TimeData object and convert its vector of dates into Array(ASCIIString, n).

datesAsNumbers(dats::Array{Date, 1})

Convert vector of dates into Array{Float64, n}.

datesAsNumbers(tm::AbstractTimedata)

Take TimeData object and convert its vector of dates into numbers: Array{Float64, n} for Date and DateTime entries.

Type preserving functions

hcat(inst::AbstractTimedata, inst2::AbstractTimedata)

Horizontal concatenation of TimeData objects. Requires objects to be of equal type with completely equal time indices. Result will be of same type as input arguments.

hcat(inst::AbstractTimedata...)

Variable argument extension of hcat.

vcat(inst::AbstractTimedata, inst2::AbstractTimedata)

Vertical concatenation of TimeData objects. Requires objects to be of equal type with equal column names and equal time index types. Result will be of same type as input arguments.

vcat(inst::AbstractTimedata...)

Variable argument extension of vcat.

flipud(inst::AbstractTimedata)

Flip TimeData object upside down.

Conversion functions

asArrayOfEqualDimensions(arr::Array, td::AbstractTimedata)

Extend row or column vector to two-dimensional array through copying values.

asTd(arr::Array, td::Timedata)

Extend row or column vector to size of Timedata object similar to repmat and return it as Timedata object with equal index and names.

asTn(arr::Array, td::Timenum)

Extend row or column vector to size of Timenum object similar to repmat and return it as Timenum object with equal index and names.

asTm(arr::Array, td::Timematr)

Extend row or column vector to size of Timematr object similar to repmat and return it as Timematr object with equal index and names.

convert(::Type{AbstractTimedata}, ta::TimeArray)

Convert TimeArray to TimeData object.

DataFrame extensions

composeDataFrame(vals, nams)

Compose DataFrame from Array and column names.

round(df::DataFrame, nDgts::Int)

Return DataFrame with rounded values. DataFrame entries must be numeric.

round(df::DataFrame)

Return DataFrame with values rounded to two significant digits. DataFrame entries must be numeric.

@roundDf(expr::Expr)

Display rounded DataFrame. Works with non numeric values also.

Display functions

display(tn::AbstractTimedata)

Timedata display function in standard REPL.

writemime(io::IO, ::MIME"text/html", td::AbstractTimedata)

Timedata display function in ijulia.

writemime(io::IO, ::MIME"text/html", tm::AbstractTimematr)

Timematr display function in ijulia. Values are rounded due to parsimony.

@table(title::String, expr::Union(Expr, Symbol))

Display expression or symbol in HTML with blue title header.

str(tn::AbstractTimedata)

More detailled display function similar to R syntax.

Statistics functions

mean(tm::AbstractTimematr, dim::Int = 1)

Return mean column values as DataFrame.

rowmeans(tm::AbstractTimematr)

Return mean row values as Timematr.

prod(tm::AbstractTimematr, dim::Int = 1)

Return product of column values as DataFrame.

rowprods(tm::AbstractTimematr)

Return product of row values as Timematr.

sum(tm::AbstractTimematr, dim::Int = 1)

Return sum of columns as DataFrame.

rowsums(tm::AbstractTimematr)

Return sum of rows as Timematr.

cov(tm::AbstractTimematr)

Return covariance matrix as DataFrame.

cor(tm::AbstractTimematr)

Return correlation matrix as DataFrame.

std(tm::AbstractTimematr)

Return empirical standard deviation for each column as DataFrame.

std(tm::AbstractTimematr, dim::Integer)

Return empirical standard deviation for each column as DataFrame.

minimum(tm::AbstractTimematr)

Return minimum value as single value.

minimum(tm::AbstractTimematr, dim::Integer)

Return minimum values of each column as DataFrame.

cumsum(tm::AbstractTimematr, dim::Integer)

Calculate cumulative sums column-wise and return result as Timematr.

cumprod(tm::AbstractTimematr, dim::Integer)

Calculate cumulative products column-wise and return result as Timematr.

rowstds(tm::AbstractTimematr)

Return empirical standard deviation for each row as Timematr.

geomMean(x::AbstractTimematr; percent = true)

Calculate geometric mean for AbstractTimedata.

geomMean(x; percent = true)

Calculate geometric mean for Array.

movAvg(tm::AbstractTimematr, nPeriods::Integer)

Calculate moving average.

I/O

readTimedata(filename::String)

Load csv and parse date column as idx.

writeTimedata(filename::String, td::AbstractTimedata)

Write TimeData object to csv file.

Join functions

For the case of monotonically increasing index values, join operations can be speeded up. The following join implementations exist. All return a Timedata object.

joinSortedIdx_inner(td1::AbstractTimedata, td2::AbstractTimedata)

Inner join of object indices.

joinSortedIdx_left(td1::AbstractTimedata, td2::AbstractTimedata)

Left join of object indices.

joinSortedIdx_right(td1::AbstractTimedata, td2::AbstractTimedata)

Right join of object indices.

joinSortedIdx_outer(td1::AbstractTimedata, td2::AbstractTimedata)

Outer join of object indices.