I have a golem app that loads data from an open government data portal. I need to access the data both in the ui (to make the choices fit the data) and in the server (to make a table and a plot), and I need the data to be up-to-date. Because I want the latest data, I do not load it as raw data and package it with the app. If this were not golem, I would probably load it at the top of the app.R
file, thereby making it available both for the ui and the server. I ended up running the data-loading function in the file of the data-loading function, which seems like a bit of a hack. I found other golem apps (e.g. this one) that load the data in the server, where it would be up-to-date but not available to the ui. Where would you recommend to load data - within the golem framework - in a way that it is more or less up to date and available for both the ui and the server?
Asked
Active
Viewed 149 times
2

gira
- 175
- 6
-
1As this is written, I think this post's question is a better fit here: https://community.rstudio.com/c/shiny/8 If you reformulate the question to not ask for a recomendation, but include code with an error, it will be suitable here. – John Polo Dec 24 '22 at 12:10
-
Did you solve this? I noticed you use `data_vector` but I do not see where it is defined. Edit: I see now it is a function: `get_zurich_data()` – its.me.adam Feb 06 '23 at 21:22
-
Why not just use the function? – its.me.adam Feb 07 '23 at 15:47
1 Answers
0
I ran into the same issue attempting to use tidymodules and the developers offered this solution:
To do what you cant to do with R6, you can use the @include roxygen skeleton, that will generate a Collate entry in the DESCRIPTION file, and R will load the file in a specific order. Please see https://roxygen2.r-lib.org/reference/update_collate.html.
Another approach would be to define your R6 class as data object: https://r-pkgs.org/data.html

D3SL
- 117
- 8