What is Julia's best approximation to attributes of R objects?

I store important metadata in R objects as attributes. I want to port my workflow to Julia, and I'm looking for a way to present at least temporary attributes as something Julia can access. Then I can start thinking about expanding the package RDatato populate this data structure with attributes of real objects.

I understand that by commenting on things like label or unit in a DataFrame, I think that the most important use of object attributes is likely to be implemented in the package DataFramesfor some time ( https://github.com/JuliaData/DataFrames.jl/issues/ 35 ). But I'm asking for a more general solution that does not depend on this particular use case.


For anyone interested, here is a related discussion in the packageRData

+4
source share
1 answer

In Julia, it’s ideal to define your own types — you simply make fields in the type to hold attributes. In R, the good thing about storing things as attributes is that they do not affect how the type sends - for example, adding metadata to a vector does not cause it to stop behaving like a vector. In julia, this approach is a bit more complicated - you will need to define an interface AbstractVectorfor your type https://docs.julialang.org/en/latest/manual/interfaces/#man-interface-array-1 to have it behave like a vector.

, , . R . - Julia , :

function ex()
    res = rand(5)
    met = "uniformly distributed random numbers"
    res, met
end

result, metadata = ex()

, , R.

+4

Source: https://habr.com/ru/post/1688198/


All Articles