Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist R objects across pages #498

Open
kwcooper opened this issue Dec 6, 2022 · 0 comments
Open

Persist R objects across pages #498

kwcooper opened this issue Dec 6, 2022 · 0 comments

Comments

@kwcooper
Copy link

kwcooper commented Dec 6, 2022

Hi! I ran into the same problem of needing to accesses previously initialized R objects as the user here posted in the groups page. Given that I needed to store an entire dataframe, however, the suggested answer (storing the result of the calculation) didn't seem as apt to my situation.

What somewhat works is to store the dataframe as a JSON file, via jsonlite::toJSON(dataframe) in a calculate label, and then continually read in the dataframe for each page, via jsonlite::fromJSON(json_df), then resave it for the next page. At best though, this is a bit hacky, and at worst, it doesn't meet all edge cases.

My guess is that the difficulties are due to each page in the survey creating a new R session? (although this is just my assumption, I couldn't find any description of how the backend R works in the documentation) Yet, if formr is able to store the result of the calculations to persist via survey_name$variable_name, I'm curious if my assumption is wrong, and maybe there is a better way? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant