commit ce48aba596ef849c5d3e27c4653d28b1e8d524b0
parent cb0a3f98154c270e99c6acbceb3651282e81a9ea
Author: Erik Loualiche <eloualic@umn.edu>
Date: Tue, 20 May 2025 18:48:45 -0500
docstrings
Diffstat:
2 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/docs/Manifest.toml b/docs/Manifest.toml
@@ -53,7 +53,7 @@ version = "1.11.0"
deps = ["ColorSchemes", "Crayons", "DataFrames", "Dates", "Interpolations", "Missings", "PrettyTables", "Random", "StatsBase"]
path = ".."
uuid = "9777a11d-2328-4b97-9b51-b265bb408da6"
-version = "0.7.1"
+version = "0.7.2"
[[deps.BitFlags]]
git-tree-sha1 = "0691e34b3bb8be9307330f88d1a3c3f25466c24d"
diff --git a/src/TimeShift.jl b/src/TimeShift.jl
@@ -3,6 +3,16 @@
# --------------------------------------------------------------------------------------------------
+# ```@example
+# julia> x = [1, 2, 3]
+# julia> t = [1, 2, 3]
+# julia> tlag(x, t, n = 1)
+# 3-element Vector{Union{Missing, Int64}}:
+# missing
+# 1
+# 2
+
+
# --------------------------------------------------------------------------------------------------
"""
tlag(x, t_vec; n = nothing, checksorted = true, verbose = false)
@@ -38,10 +48,14 @@ backward in time by a specified amount `n`.
- If `n` has a type that doesn't match the difference type of `t_vec`
# Examples
-```jldoctest
-x = [1, 2, 3, 4, 5]
-t = [Date(2023,1,1), Date(2023,1,2), Date(2023,1,3), Date(2023,1,4), Date(2023,1,5)]
-tlag(x, t, n = Day(1)) # Returns: [missing, 1, 2, 3, 4]
+```@example
+x = [1, 2, 3]
+t = [1, 2, 3]
+tlag(x, t, n = 1)
+3-element Vector{Union{Missing, Int64}}:
+ missing
+ 1
+ 2
```
"""
@@ -137,10 +151,14 @@ forward in time by a specified amount `n`.
- If `n` has a type that doesn't match the difference type of `t_vec`
# Examples
-```jldoctest
-x = [1, 2, 3, 4, 5]
-t = [Date(2023,1,1), Date(2023,1,2), Date(2023,1,3), Date(2023,1,4), Date(2023,1,5)]
-tlead(x, t, n = Day(1)) # Returns: [2, 3, 4, 5, missing]
+```@example
+x = [1, 2, 3]
+t = [8, 9, 10]
+tlead(x, t, n = 1)
+3-element Vector{Union{Missing, Int64}}:
+ 2
+ 3
+ missing
```
"""
@@ -226,14 +244,24 @@ by a specified amount `n`. Acts as a unified interface to `tlag` and `tlead`.
- If `n` is not specified, issues a warning and defaults to a lag operation
# Examples
-```jldoctest
-x = [1, 2, 3, 4, 5]
-t = [Date(2023,1,1), Date(2023,1,2), Date(2023,1,3), Date(2023,1,4), Date(2023,1,5)]
-tshift(x, t, n = Day(1)) # Lag: [missing, 1, 2, 3, 4]
-tshift(x, t, n = -Day(1)) # Lead: [2, 3, 4, 5, missing]
+```@example
+x = [1, 2, 3];
+t = [-3, -2, -1];
+tshift(x, t, n = 1)
+3-element Vector{Union{Missing, Int64}}:
+ missing
+ 1
+ 2
+
+tshift(x, t, n = -1)
+3-element Vector{Union{Missing, Int64}}:
+ 2
+ 3
+ missing
+
```
-See also: tlag, tlead
+See also: [`tlag`](@ref), [`tlead`](@ref)
"""
function tshift(x, t_vec; n=nothing, kwargs...)