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

dashBoardUser (... , src = {local file}, ... ), how to address the local file in a package? #42

Closed
DavidPatShuiFong opened this issue Jun 11, 2019 · 3 comments

Comments

@DavidPatShuiFong
Copy link

I was able to use a local .svg file as the icon file (as defined by src=).

I used a reference like src = "./assets/icons/user-avatar.svg", where assets is a directory under www.

I am now packaging my application, so I moved the www directory to the inst directory and changed the src reference to src = "./www/assets/icons/user-avatar.svg". That doesn't work.

Even worse, I can't figure out a way to know how to figure out what is wrong with the file reference!

Thanks for any help

image

@DivadNojnarg
Copy link
Member

Hi David,

you don't need to set this path for images "./www/assets/..."
Simply let "assets/my_image.svg".

Moreover, try to rename your main file "app.R" and launch it with the run App button in the central panel.

This is issue is unfortunately not related to the shinydashboardePlus package.

@DivadNojnarg
Copy link
Member

DivadNojnarg commented Jun 12, 2019

In a package I usually create some custom path for my images such as:

.onAttach <- function(libname, pkgname) {
  addResourcePath('logos', system.file("logos", package = "CaPO4Sim"))
  addResourcePath('CaPO4_network', system.file("CaPO4_network", package = "CaPO4Sim"))
}

I put this in a zzz.R file for instance.

All my images are contained in the inst folder but I don't need to use "inst/CaPO4_network" when providing links.

Have a look at https://github.com/DivadNojnarg/CaPO4Sim

@DavidPatShuiFong
Copy link
Author

Thanks Divad, that worked! I gradually discovered through more searching that 'addResourcePath' and 'system.file' might be part of the solution, but strangely none of the other answers on StackOverflow etc. did what you did. More importantly, none of the other solutions actually worked in a 'package' situation. (I'll try to add your effective answer to some of those questions on StackOverflow)

Thanks even more for the example. I found what I was looking for in the R/zzz.R and R/network_utils.R.

My apologies, I see now that this is a general 'how to write R packages' issue, rather than a shinydashboardplus problem. So, extra thanks for the help!

DavidPatShuiFong added a commit to DavidPatShuiFong/DailyMeasure that referenced this issue Jun 12, 2019
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

2 participants