htmlwidgets

Clicking a leaflet marker takes you to URL

丶灬走出姿态 提交于 2019-12-07 04:44:35
问题 Within the leaflet package for R, is there a way to click on a marker, and be directed to a URL?* This seems to be possible in JS. It's easy to add a standalone Popup with a URL: library(leaflet) content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>" ) leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) It's also straightforward to add a Marker that, when clicked, provides a URL in

How to control node labels in Sankey diagram

元气小坏坏 提交于 2019-12-06 16:09:03
问题 I have a Sankey diagram I'm creating in R. It produces the diagram but the node names are placed on the left of the nodes for the right side nodes. I would like all names to be on the right so the real names (which are longer) don't overlap with each other. Below is a complete set of working code that will generate the diagram I am currently working with. library(networkD3) nodes <- data.frame('name' = c('Node0','Node1','Node2','Node3','Node4','Node5','Node6', 'Node7','Node8','Node9','Node10'

Generate formattable widgets in a loop in an R markdown document

为君一笑 提交于 2019-12-06 04:37:39
I want to put HTML widgets like formattable (from formattable package) in an HTML page generated through RMarkdown. I need the widgets to be generated from within a for loop. How can i do that? With or without print() , both don't work. This is an example code (partly taken from formattable homepage ): --- title: "formattable example loop" output: html_document --- ```{r} library(formattable) df <- data.frame( id = 1:10, name = c("Bob", "Ashley", "James", "David", "Jenny", "Hans", "Leo", "John", "Emily", "Lee"), age = c(28, 27, 30, 28, 29, 29, 27, 27, 31, 30), grade = c("C", "A", "A", "C", "B"

Clicking a leaflet marker takes you to URL

早过忘川 提交于 2019-12-05 11:04:09
Within the leaflet package for R, is there a way to click on a marker, and be directed to a URL?* This seems to be possible in JS . It's easy to add a standalone Popup with a URL: library(leaflet) content <- paste(sep = "<br/>", "<b><a href='http://www.samurainoodle.com'>Samurai Noodle</a></b>" ) leaflet() %>% addTiles() %>% addPopups(-122.327298, 47.597131, content, options = popupOptions(closeButton = FALSE) ) It's also straightforward to add a Marker that, when clicked, provides a URL in the popup: leaflet() %>% addTiles() %>% addMarkers(-122.327298, 47.597131, popup = content, options =

Creating a Sankey Diagram using NetworkD3 package in R

冷暖自知 提交于 2019-12-05 01:22:28
问题 Currently I am trying to create an interactive Sankey with the networkD3 Package following the instructions by Chris Grandrud (https://christophergandrud.github.io/networkD3/). What I don't understand is is table-format, since he just uses two columns for visualising more transitions. To be more specific, I have a dataset containing four columns which represent 4 years. Inside these columns are different hotel names, whereas each row represents one customer, who is "tracked" over these four

saving R leaflet map as html: tiles not included

做~自己de王妃 提交于 2019-12-04 22:26:12
问题 I am trying to save an R leaflet map, using saveWidget() or outputting an rmd-file to html - as described here: Saving leaflet output as html When generating an html-file with markdown, the map will show fine in the internal rstudio viewer, however if I open the generated html file or the html-file produced by saveWidget() in a browser, only the circles are shown, not the tiles. Minimal example: ```{r} library(leaflet) library(htmlwidgets) m <- leaflet(data.frame(lat = 55.71654, lng = 12

Interactively adding points to plotly R without redrawing background plot

心不动则不痛 提交于 2019-12-04 19:02:26
The MWE below oversimplifies my real goal. However, I have a background image that takes a long time to draw (in the example below it is simply a scatterplot of 32 mtcars dataset values). Users can click on certain points from my background image, and this will cause new points to be plotted. My aim is for these new points to simply be redrawn on the top layer, while the background image scatterplot does not need to be redrawn to save time and computation. My MWE is as follows: library(plotly) library(htmlwidgets) g <- ggplot(mtcars, aes(x=mpg, y=cyl)) + geom_point() gP <- ggplotly(g) gP %>%

How to plot a directed Graph in R with networkD3?

99封情书 提交于 2019-12-04 17:11:45
when I am ploting a directed graph with NetworkD3 , The edges are not directed , how can I fix it ? an Example : library(networkD3) data(MisLinks) data(MisNodes) forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8) I want the result to be directed This is the definetion of directed Graph: "A directed graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together, where all the edges are directed from one vertex to another. A directed graph is sometimes called a

Conditional formatStyle in DT

有些话、适合烂在心里 提交于 2019-12-04 16:48:52
I want to color rows in column A by values in column B. The code below is based on the example from the vignette Link , but shows only the condition for two columns: mobile_number by mobile_flag. Data: head(test[, c("EMBG","mobile_number", "home_number", "mobile_flag", "home_number_flag")]) EMBG mobile_number home_number mobile_flag 1 101001455126 075-201-543 02/2446-275 correct 2 101010455015 55555555555 55555555555 incorrect 3 101014455095 0 0 incorrect 4 101947455134 075/482-356 02/2460-020 correct 5 101952450264 070 22 16 18 ---------------- correct 6 101953450012 0 02/2446-276 incorrect

Modify networkD3 sankey plot with user-defined colors

点点圈 提交于 2019-12-04 13:27:55
问题 I have a sankey plot created in networkD3 package. I would like to modify the colors and transparency of both nodes and links. My data networkD3_data is appended at the end. Question 1: How to modify node colors with user-defined palette? I am not sure how to modify the colors with user-defined palette. It is necessary for me to use the same color palette specific to each node source to keep consistent with other plots I have. Currently I am able to have each source node be a different color