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

Calling data in ui.R saved in data-raw #127

Closed
dilsherdhillon opened this issue Aug 11, 2019 · 8 comments
Closed

Calling data in ui.R saved in data-raw #127

dilsherdhillon opened this issue Aug 11, 2019 · 8 comments

Comments

@dilsherdhillon
Copy link

I'm trying to develop a simple app that takes in a pre-trained model(*.RDS), and given the input by user, outputs predictions. <30 lines of code.

I now want to package this up in an app, and eventually docker + shinyproxy.

My question is -
What path do I use to call the model in my ui.R file, if I keep my data in the data-raw folder?
This is what I'm using but when I run it, it says model_1 not found.

model_1 <- readRDS("data-raw/trained_model.rds")  

## the UI stuff below here

How do I ensure my relative path when reading in the model object in ui.R calls in the model?

@VincentGuyader
Copy link
Member

VincentGuyader commented Aug 11, 2019

Hi,

the data-raw folder will not be present in your builded package. you cant use it in your app.
a nice way to do what you need is to put your rds file inside the inst/extdata folder and to use :

readRDS(system.file("extdata","plop.rds",package = "yourgolem")))

Regards

@ColinFay
Copy link
Member

Just as any package the data-raw folder is ignored when build, so you can't refer to data from there.

As far as I see it if you need something accessible in your UI, you should:

Does it do what you need? Let me know if you need a more detailed example

@dshelldhillon
Copy link

Hi Vincent and Colin -
Thank you for your help and sorry for the late reply. I've been out and will give this a try and close the issue.
Once again, thanks a ton!!

Dilsher

@ColinFay
Copy link
Member

Ok so I thought this through and realized it's way easier than that with the way {golem} is implemented.

You just have to:

Screenshot 2019-08-21 at 22 52 06

@ColinFay
Copy link
Member

hi @dilsherdhillon

Have you worked on that? Do you need any more info?

Don't hesitate to close the issue if everything is ok :)

@dshelldhillon
Copy link

Sorry! Yes it worked - thank you so much for this package!

@ajmoralesa
Copy link

Ok so I thought this through and realized it's way easier than that with the way {golem} is implemented.

You just have to:

Screenshot 2019-08-21 at 22 52 06

@ColinFay I'm having troubles with this in a dockerized golem app. Everything works well when I install or test locally the app, but when running a docker container, I keep having:

Listening on http://0.0.0.0:3838
Warning: Error in get: object 'db_coord' not found
  [No stack trace available]

As suggested here, I called explicitly the data set using mypackage::mydataset, but the error remains. I also tested your suggestions but did not resolve the issue either.

Do you have any idea of what can be happening? Many thanks in advance!

@ajmoralesa
Copy link

I guess my issue is related to #413 and more specifically #321

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

5 participants