# \donttest{
f_obs <- tempfile(fileext = ".vtr")
f_sp <- tempfile(fileext = ".vtr")
f_ct <- tempfile(fileext = ".vtr")
write_vtr(data.frame(sp_id = 1:4, ct_code = c("AT", "DE", "FR", "XX"),
value = 10:13), f_obs)
write_vtr(data.frame(sp_id = 1:3,
name = c("Oak", "Beech", "Pine")), f_sp)
write_vtr(data.frame(ct_code = c("AT", "DE", "FR"),
gdp = c(400, 3800, 2700)), f_ct)
s <- vtr_schema(
fact = tbl(f_obs),
species = link("sp_id", tbl(f_sp)),
country = link("ct_code", tbl(f_ct))
)
# Pull columns from any linked dimension
result <- lookup(s, value, species$name, country$gdp)
collect(result)
unlink(c(f_obs, f_sp, f_ct))
# }
Run the code above in your browser using DataLab