这应该是一个简单的问题,但我找不到任何相关文档或之前的问答。使用 Julia 进行子集化很容易,尤其是使用 @Chain 命令时。但我一生都没有找到一种方法来对日期进行子集化:
maindf = @chain rawdf begin
@subset(Dates.year(:travel_date) .== 2019)
end
Run Code Online (Sandbox Code Playgroud)
在所有文档中 Dates.year(today()) 应该产生 (2021) 但这最终给我带来了一个错误:
ERROR: MethodError: no method matching +(::Vector{Date}, ::Int64)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at operators.jl:560
+(::T, ::T) where T<:Union{Int128, Int16, Int32, Int64, Int8, UInt128, UInt16, UInt32, UInt64, UInt8} at int.jl:87
+(::T, ::Integer) where T<:AbstractChar at char.jl:223
Run Code Online (Sandbox Code Playgroud)
不确定为什么我会收到方法错误..
在使用 DPLYR 的 R 中,这只是:
maindf = rawdf %>%
filter(., year(travel_date) == 2019)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?