I have to use Julia for a problem set for class. I've never used it before and I've only ever really used Matlab/Stata.
I want to initialize an empty date vector, so that I can store values in it in a for loop. The for loop will have a lot of if statements that will change how I input into the date vector. It'd be something like this:
using Dates
date = vector(N,1) # Need help with this line
for i in 1:N
if stuff1
date[i] = blah1
elseif stuff2
date[i] = blah2
else
date[i] = blah3
end
end
Use:
julia> N = 5
5
julia> date = Vector{Date}(undef, N)
5-element Vector{Date}:
56207879210758--12056695473012767-3689348814741910322
97580475146329-6028347736506381-7378697629483820659
-99964444404694-24113390946025549-7378697629483820668
-54150401430865--30141738682531934-3689348814741910309
0001-02-07
for an uninitialized vector, or:
julia> fill(Date(2022, 03, 18), N)
5-element Vector{Date}:
2022-03-18
2022-03-18
2022-03-18
2022-03-18
2022-03-18
to initially fill it with some default value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With