Skip to content
This repository has been archived by the owner on Apr 10, 2019. It is now read-only.

Location of Html file in Basic R #13

Closed
alanmcmahon opened this issue May 13, 2016 · 8 comments
Closed

Location of Html file in Basic R #13

alanmcmahon opened this issue May 13, 2016 · 8 comments

Comments

@alanmcmahon
Copy link

Hi,

I'm fairly new to R, so my apologies if my question is basic.

I'm having trouble understanding if I can control the location of the html page when created direct from the R console.
I'm not using shiny or R studio, and the resulting chart loads in my browser from a subfolder within the tempdir() in R. Is there a way to change this?
I've tried to use the chartJSRadar_html, but am unsure what I should specify?

Thanks :)

@dougmet
Copy link
Contributor

dougmet commented May 13, 2016

Do I understand correctly; you'd like to capture the html generated and save as a static web page? That's an interesting one, might have to be a new feature.

@gaborcsardi
Copy link

gaborcsardi commented May 13, 2016

You can set the viewer option to a function, and then htmlwidgets will call that function with the name of the output file, which then you can save it or do as you like with it. Note that usually this is not a standalone file, it loads JS libs, at least for the cases I tried.

library(radarchart)
options(viewer = function(url, ...) print(url))
chartJSRadar(scores = skills)
#> [1] "/var/folders/ws/7rmdm_cn2pd8l1c3lqyycv0c0000gn/T//RtmpThXIWA/viewhtml577e8c720f9/index.html"

@alanmcmahon
Copy link
Author

Thanks for this,

I guess it need not be a static webpage, but rather if I could control the location of the files created, such that they point to a user defined location (rather than the tempdir()).

I'll see what I can do with the options and viewer function.

@timelyportfolio
Copy link
Contributor

@alanmcmahon, the built-in saveWidget function of htmlwidgets might be what you need. Happy to help, but ?htmlwidgets:::saveWidget will get you started.

@gaborcsardi
Copy link

@timelyportfolio Thanks, saveWidget looks awesome! Actually, it is exported, so htmlwidgets::saveWidget works as well. Thanks again!

@timelyportfolio
Copy link
Contributor

timelyportfolio commented May 13, 2016

Also, this wch/webshot#10 (comment) might help if you are ok using a tagList from htmltools.

@gaborcsardi, I think the saveWidget doesn't get nearly enough love, but I use all the time. It is my preferred way to go from htmlwidget to gist in < 1 minute.

A lot of htmlwidget authors provide a method that just wraps saveWidget, but I think it would be better just to flood the world with saveWidget examples. :)

@alanmcmahon
Copy link
Author

Excellent. Tried it and it is perfect. Thank you so much :)

@dougmet
Copy link
Contributor

dougmet commented May 24, 2016

Thanks all, saveWidget looks like a great solution. Closing.

@dougmet dougmet closed this as completed May 24, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants