htmlwidgets

R : combine and save rgl widgets as a single html file

混江龙づ霸主 提交于 2021-02-18 16:05:57
问题 In R, using the rgl and htmlwidgets libraries, I'm trying to extract an HTML file having a widget with toggle buttons . The following example does what I want in the RStudio Viewer. The HTML export works without the toggle buttons, but fails when the rglwidget includes these buttons. The first part is based on these rgl examples, and the export part on the htmlwidgets manual. library(rgl) open3d() x <- sin(1:100) y <- cos(1:100) z <- -100:100/100 # draw a barrel sids1 <- spheres3d(x, y, z,

plotly: exposing the “config” object in the stored JSON string, for easier use with Plotly.JS functions

大城市里の小女人 提交于 2021-02-11 12:33:33
问题 I don't know whether this is a plotly question or an htmlwidgets question. Maybe it's both. I am using R to make plotly widgets, which are -- when made from R -- also htmlwidgets. When making plotly widgets in this way, the resulting HTML contains a stringified JSON object that includes the data and some settings for the widget. But only some parts of this JSON object are easily accessed from a Javascript console. For example, the "data" and "layout" objects are easily accessed, but the

structuring binary data for sankey plot

橙三吉。 提交于 2021-02-08 07:50:41
问题 I am having trouble figuring out how to make a sankey plot for data where there are multiple opportunities of success (1) or failure (0). You can generate my sample with the following code: # example library(networkD3) library(tidyverse) library(tidyr) set.seed(900) n=1000 example.data<-data.frame("A" = rep(1,n), "B" = sample(c(0,1),n,replace = T), "C" = rep(NA,n), "D" = rep(NA,n), "E" = rep(NA,n), "F" = rep(NA,n), "G" = rep(NA,n)) for (i in 1:n){ example.data$C[i]<- ifelse(example.data$B[i]=

structuring binary data for sankey plot

霸气de小男生 提交于 2021-02-08 07:50:21
问题 I am having trouble figuring out how to make a sankey plot for data where there are multiple opportunities of success (1) or failure (0). You can generate my sample with the following code: # example library(networkD3) library(tidyverse) library(tidyr) set.seed(900) n=1000 example.data<-data.frame("A" = rep(1,n), "B" = sample(c(0,1),n,replace = T), "C" = rep(NA,n), "D" = rep(NA,n), "E" = rep(NA,n), "F" = rep(NA,n), "G" = rep(NA,n)) for (i in 1:n){ example.data$C[i]<- ifelse(example.data$B[i]=

Using R and plot.ly, how to save multiples htmlwidgets to my html?

☆樱花仙子☆ 提交于 2021-02-08 02:20:23
问题 I´m starting to play with plot.ly in R and I´m amazed with the possibilities to publish my graphs directly in html using htmlwidgets. Until now I´m unable to save multiple widgets in the same html. I have saved multiple widgets in stand-alone htmls and than combine it by hand in the html code, but I would like to be able to do it in R. A simple example: #graph graph<- ggplot(df, aes(x = Data, y=tax))+ geom_bar(stat='identity') gg <- ggplotly(graph) # save as HtmlWigdet htmlwidgets::saveWidget

Using R and plot.ly, how to save multiples htmlwidgets to my html?

可紊 提交于 2021-02-08 02:11:31
问题 I´m starting to play with plot.ly in R and I´m amazed with the possibilities to publish my graphs directly in html using htmlwidgets. Until now I´m unable to save multiple widgets in the same html. I have saved multiple widgets in stand-alone htmls and than combine it by hand in the html code, but I would like to be able to do it in R. A simple example: #graph graph<- ggplot(df, aes(x = Data, y=tax))+ geom_bar(stat='identity') gg <- ggplotly(graph) # save as HtmlWigdet htmlwidgets::saveWidget

Error in eval(lhs, parent, parent) : object 'countries_sf' not found >

耗尽温柔 提交于 2021-01-29 11:47:35
问题 When I tried to run the code, for some reason, one of the objects "not found". I tried to chance the name, run again, but it's always the same error. The code: countries_sf <- countries110 %>% st_as_sf() pop_palette <- colorNumeric("viridis", domain = countries_sf$gdp_md_est) countries_sf %>% filter(! name == "Antarctica") %>% leaflet() %>% the error message: Error in eval(lhs, parent, parent) : object 'countries_sf' not found 来源: https://stackoverflow.com/questions/56471516/error-in-evallhs

enable horizontal movement of nodes in networkD3's sankeyNetwork plots

∥☆過路亽.° 提交于 2021-01-29 10:44:16
问题 I found this image from the Internet (link) and I think it was draw in R. I tried to reproduce this Figure and make it more or less similar with one from the above link. The code I used is as following: ID <- 0:24 NodeGroup <- c(rep(1,8),2,5,rep(4,7),3,5,6,6,7,7,8,9) name <- c("29581k","5279k","4218k","1917k","1356k","Ventas diversas: 116","Venta diversa: 97","Venta de: 141","Venta totales: 42705","Contribucion marginal: 18183", "17531k","1744k","1326k","1208k","526k","459k","14k","IIBB: 1714

Merge 1000 HTML files in R

老子叫甜甜 提交于 2021-01-28 06:08:48
问题 I have more than 1000 html files and I want to merge them together. I have provided the code below how I am doing it. But it's not getting merge and I am getting blank html file(merged). saveWidget(f1, "f1.html") saveWidget(f2, "f2.html") saveWidget(f3, "f3.html") saveWidget(f4, "f4.html") and so on till saveWidget(f1000, "f1000.html") Code to merge files: library(htmlwidgets) htmlFiles<-list.files("/path/") library(htmltools) widgets <- list(htmlFiles) #fns <- replicate(length(widgets),

How to specify the colors and toggle labels for each category in R sunburst?

為{幸葍}努か 提交于 2021-01-28 05:49:53
问题 I can't seem to understand how sunburst in the sunburstR package handles certain paramenters, namely the vector of colors given to it and how it applies the colors towards the different categories, as well as how to show the labels for the different partitions. Is there a logic to it, and is there a better way to manually specify which color should go with which root/leaf? From ?sunburst : (No idea what they mean by "supply a list with range and/or domain." colors vector of strings