htmlwidgets

linking a node in networkD3 to a website using clickAction = NULL

霸气de小男生 提交于 2019-11-30 17:04:20
Is there a way to use a node as a link to an external website using the function forceNetwork() in the networkD3 package in r ? I was thinking maybe modifying the clickAction ? Example data: library(networkD3) data(MisLinks) data(MisNodes) # Create a random URL in the nodes dataset MisNodes$URL <- paste0("http://www.RANDOMLINK_", sample(1:100, NROW(MisNodes)), ".com") head(MisNodes) MyClickScript <- 'alert(d.index)' forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8, clickAction = MyClickScript

Sankey diagram in R

这一生的挚爱 提交于 2019-11-30 09:07:35
Attempting to make a fairly generic Sankey diagram with the help of R's networkD3 package. Just for reference--here's the example from the package's manual library(networkD3) library(jsonlite) library(magrittr) energy <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json" %>% fromJSON sankeyNetwork(Links = energy$links, Nodes = energy$nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", units = "TWh", fontSize = 12, nodeWidth = 30) which results in: My fairly straightforward extension consists of building a diagram with the following

Is it possible to include custom css in htmlwidgets for R and/or LeafletR?

这一生的挚爱 提交于 2019-11-30 08:45:38
问题 I'd like to make some style changes to my leaflet map. Is it possible to include style elements OR a custom path to a css file either via htmlwidgets for R or LeafletR? Best 回答1: With no code whatsoever in your question, answering is very difficult. I'll attempt an answer. There are two methods of adding custom CSS to an htmlwidget . I will caution up front though that you will need to be very specific or use the !important override, since there is already quite a bit of CSS that is

Own colour range for Sankey Diagram with networkD3 package in R

爷,独闯天下 提交于 2019-11-30 05:39:27
问题 I am trying to plot Sankey diagrams using sankeyNetwork() in networkD3 package. sankeyNetwork(Links = Flow_data, Nodes = Nodes_data, Source = "Source_ID", Target = "Target", Value = "value", NodeID = "Nodes_name", width = 1000, height=600, fontsize = 16, nodeWidth = 50, colourScale = "d3.scale.category20c()") The visualization works great but I would like to change the colour range to an individual range. Is there any chance to change the colours of the SankeyNetwork? I need a range of only e

How to arrange HTML Widgets inside of a RMarkdown Document (PDF, HTML)

只愿长相守 提交于 2019-11-30 04:58:27
问题 I'm working in a R notebook and would like use it to create two ouptuts: an HTML document and PDF document. My analysis includes leaflet maps (html widgets), which is causing problems when I knit the notebook to a PDF document . Thanks to the webshot function now included in the knitr package, "knitr will try to generate static screenshots for HTML widgets automatically using the webshot package" (https://github.com/yihui/knitr/blob/master/NEWS.md). This works fine when my output is a series

savewidget from htmlwidget in R , cannot save html file in another folder

我们两清 提交于 2019-11-30 01:33:01
问题 I have a map leaflet that I want to save in an html file in a specific folder. I am using Windows 7. I tried the following : library(htmlwidgets) saveWidget(map_leaflet, file="ressources/test.html") library(htmlwidgets) saveWidget(map_leaflet, file="ressources\\test.html") library(htmlwidgets) path_name <- file.path("ressources", "test.html", fsep="\\") saveWidget(map_leaflet, file=path_name) library(htmlwidgets) path_name <- paste("ressources", "test.html", sep="/") saveWidget(map_leaflet,

R Shiny includeHTML missing htmlWidgets in a reactive context

回眸只為那壹抹淺笑 提交于 2019-11-29 17:06:00
UPDATE: I posted a related question here I need to include an html file in shiny using includeHTML. The file is generated by rmarkdown, and has a large number of htmlWidgets. Shiny is showing the html file, but the htmlWidgests are missing. The problem occurs only when includeHTML is in server.R, but works ok if includeHTLM is in ui.R. I need to update file.html so includeHTML must be used in a reactive context. The file.rmd is somthing like this --- title: "test" author: "me" date: '`r Sys.Date()`' output: html_document --- ```{r} df<- data.frame(a = c(1:10), b = c(1:10)) rpivotTable:

Interactive `ggplotly` graph is not plotted from inside `for` loop in `Rmd` file in R

帅比萌擦擦* 提交于 2019-11-29 12:41:59
问题 I tried to plot series of interactive ggplotly graphs from inside for loop in R markdown ( .Rmd ) file. Contents of my .Rmd file: --- title: "Untitled" output: html_document --- ```{r} library(ggplot2) # for plots library(plotly) # for interactive plots # Convert 4 variables to factor variables: factor_vars <- c("vs", "am", "gear", "carb") mtcars[factor_vars] <- data.frame(Map(as.factor, mtcars[factor_vars])) for (VAR in factor_vars) { cat(paste("Factor variable:", VAR)) # Contents of "VAR"

Is it possible to include custom css in htmlwidgets for R and/or LeafletR?

删除回忆录丶 提交于 2019-11-29 07:46:12
I'd like to make some style changes to my leaflet map. Is it possible to include style elements OR a custom path to a css file either via htmlwidgets for R or LeafletR? Best With no code whatsoever in your question, answering is very difficult. I'll attempt an answer. There are two methods of adding custom CSS to an htmlwidget . I will caution up front though that you will need to be very specific or use the !important override, since there is already quite a bit of CSS that is automatically added to leaflet . Easy but Less Robust htmlwidgets can be combined with tags from the htmltools

Embedding an R htmlwidget into existing webpage

偶尔善良 提交于 2019-11-28 05:51:27
I am trying to embed an R htmlwidget into an existing webpage -- a webpage that already has bootstrap and styling applied. For example, consider the following webpage (note where the widget should be placed): <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <p>This is a test.</p> <!-- htmlwidget should go here. --> <p>A closing paragraph.</p> </body> </html> I can create and save a datatable widget like so: library(htmlwidgets) library(datatable) d1 <- datatable(mtcars, filter = "top") saveWidget(d1, file = "widget_file.html") The generated