Utility functions
DataArrays.cut
— Function.cut(x::AbstractVector, breaks::Vector) -> PooledDataArray
cut(x::AbstractVector, ngroups::Integer) -> PooledDataArray
Divide the range of x
into intervals based on the cut points specified in breaks
, or into ngroups
intervals of approximately equal length.
Examples
julia> cut([1, 2, 3, 4], [1, 3])
4-element DataArrays.PooledDataArray{String,UInt32,1}:
"[1,3]"
"[1,3]"
"[1,3]"
"(3,4]"
DataArrays.gl
— Function.gl(n::Integer, k::Integer, l::Integer = n*k) -> PooledDataArray
Generate a PooledDataArray
with n
levels and k
replications, optionally specifying an output length l
. If specified, l
must be a multiple of n*k
.
Examples
julia> gl(2, 1)
2-element DataArrays.PooledDataArray{Int64,UInt8,1}:
1
2
julia> gl(2, 1, 4)
4-element DataArrays.PooledDataArray{Int64,UInt8,1}:
1
2
1
2
DataArrays.xtab
— Constant.xtab(x::AbstractArray) -> xtab
Construct a cross-tabulation table from the unique values in x
. Currently only one-way tables are supported. Returns an xtab
object.
DataArrays.xtabs
— Function.xtabs(x::AbstractArray) -> Dict
Construct a cross-tabulation table from the unique values in x
, returning a Dict
. Currently only one-way tables are supported.
DataArrays.reldiff
— Function.reldiff(v::Vector) -> Vector
For each element in v
, compute the relative difference from the previous element.
Examples
julia> reldiff([1.0, 2.0, 3.0, 4.0])
3-element Array{Float64,1}:
2.0
1.5
1.33333
DataArrays.percent_change
— Function.percent_change(v::Vector) -> Vector
For each element in v
, compute the percent change from the previous element.
Examples
julia> percent_change([1.0, 2.0, 3.0, 4.0])
3-element Array{Float64,1}:
1.0
0.5
0.333333