Is there a syntax or function to reference parent and root when querying nested Associations similar to Unix' ".." and "/", eg "cd ../../mydir". ?
Here's a typical application of the root construct. Given a nested dataset:
ds = <| "study" -> <| "all" -> <|"n" -> 223.`, "Median" -> 18.5` |>|>,
"bySite" -> <| "VASD" -> <|"n" -> 107.`, "Median" -> 20.40`|>,
"UCSD" -> <|"n" -> 116.`, "Median" -> 16.5` |>|>,
"bySpeciality" -> <|"Primary" -> <|"n" -> 127.`, "Median" -> 17.8` |>,
"Specialty" -> <|"n" -> 96.` , "Median" -> 19.5` |>|>|> // Dataset
(Dataset is only used here for formatting convenience)
using ds["study","all","n"]
as denominator, the query is to convert all values of the instances "n" to ratios:
ds[All, All, #/ds["study", "all", "n"] &]
But how can it be used in a query without reference to ds
? For example, would like to use something like RootAssociation
ds // Query[All, All, {"n" -> (#/RootAssociation["study", "all", "n"] &)}]
ParentAssociation
would work in a similar way
Comments
Post a Comment