I'm not 100% sure I understand your question, but let me give it a shot.
First thing is to note why you're getting that MethodError. It's from the
line
println(si in sdt1[i, [:BreakTime1, :BreakTime2]])
Define sdt1 as you do (I just copied into a Julia REPL) and set i = 1 to
for the first iteration of the for loop.
Then:
julia> sdt1[i, [:BreakTime1, :BreakTime2]]
1×2 DataFrames.DataFrame
│ Row │ BreakTime1 │ BreakTime2 │
├─────┼─────────────────────┼─────────────────────┤
│ 1 │ 2016-04-13T10:00:00 │ 2016-04-13T12:00:00 │
julia> si =
Dates.format([sdt1[i,:StartTime]:Dates.Minute(30):sdt1[i,:EndTime]],
"HH:MM")
WARNING: [a] concatenation is deprecated; use collect(a) instead
in depwarn at deprecated.jl:73
in oldstyle_vcat_warning at abstractarray.jl:29
in vect at abstractarray.jl:32
while loading no file, in expression starting on line 0
11-element Array{Any,1}:
"07:15"
"07:45"
"08:15"
"08:45"
"09:15"
"09:45"
"10:15"
"10:45"
"11:15"
"11:45"
"12:15"
julia> si in sdt1[i, [:BreakTime1, :BreakTime2]]
ERROR: MethodError: `start` has no method matching
start(::DataFrames.DataFrame)
in mapreduce_sc_impl at reduce.jl:194
in in at reduce.jl:377
So si is of type Vector{Any} but happens to hold strings. sdt1[i,
[:BreakTime1, :BreakTime2]] is a DataFrame. What does it mean to ask if a
vector is in a DataFrame? That's what's happening in your println; the `in`
is just an infix operator of function in.
3-element Array{Int64,1}:
1
2
3
julia> 1 in x
true
julia> in(1,x)
true
julia> in(5,x)
false
I assume you get the MethodError of no method start because in(a,b)
iterates over b, checking each element of b for equality to a. But
DataFrames are not iterable in this way. (This part just a guess; look it
up in the manual before telling your friends.)
Anyway, to get output as from your R snippet, you could use a loop like the
following:
julia> for i in 1:nrow(sdt1), t in
sdt1[:StartTime][i]:Dates.Minute(30):sdt1[:EndTime][i]
if !(t in [sdt1[:BreakTime1][i], sdt1[:BreakTime2][i]])
println("$i $(Dates.format(t, "HH:MM"))")
end
end
1 07:00
1 07:30
1 08:00
1 08:30
1 09:00
1 09:30
1 10:30
1 11:00
1 11:30
2 07:15
2 07:45
2 08:15
2 08:45
2 09:15
2 09:45
2 10:45
2 11:15
2 11:45
I hope this helps!