我似乎无法理解如何sunburst在sunburstR包处理某些paramenters中,给它的颜色以及如何应用颜色对不同类别分别是矢量,以及如何显示标签的不同分区。
它是否有逻辑,是否有更好的方法来手动指定哪种颜色应该与哪个根/叶搭配?
来自?sunburst:(不知道他们所说的“提供具有范围和/或域的列表”是什么意思。
colors
vector of strings representing colors as hexadecimal for manual colors.
If you want precise control of colors, supply a list with range and/or domain.
For advanced customization, supply a JavaScript function.
Run Code Online (Sandbox Code Playgroud)
谢谢!
sourcestatus
# A tibble: 5 x 2
SourceStatus count
<chr> <int>
1 blood-affected 4369
2 blood-unaffected 2848
3 blood-unknown 1
4 cell_line-affected 1797
5 cell_line-unaffected 151
Run Code Online (Sandbox Code Playgroud)
创建旭日:
sunburst(sourcestatus, count = TRUE, percent= T,
colors = c("#6b5b95", "#feb236", "#d64161", …Run Code Online (Sandbox Code Playgroud) 我想从用户单击小部件时删除初始值( selected=) 。selectizeInput
这是示例代码:
library(shiny)
library(dplyr)
ui= fluidPage(
sidebarLayout(
sidebarPanel(
selectizeInput(inputId= "cyl", label= "cyl",
choices= NULL,
selected= sort(unique(mtcars$cyl))[1],
multiple=T)
),
mainPanel(
tableOutput("tab")
)
)
)
server= function(input, output,session) {
updateSelectizeInput(session = session,inputId ="cyl",choices=sort(unique(mtcars$cyl)),selected=sort(unique(mtcars$cyl))[1], server = TRUE)
df_filtered= reactive({
mtcars %>%
{if (is.null(input$cyl)) . else filter(., cyl %in% input$cyl)}
})
output$tab= renderTable(df_filtered())
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
只是基于示例代码的一些解释:
selectizeInput "cyl"中的初始选定值为4。当用户按下此小部件时,我希望4 删除该值并selected清除该选项。有任何想法吗?
*我使用了该功能,updateSelectizeInput因为server在我的shiny app选择中选择很大导致加载时间太长
我有一个在 R 中创建的 Sankey 图。它生成图,但节点名称放置在右侧节点的节点左侧。我希望所有的名字都在右边,这样真实的名字(更长)就不会相互重叠。
下面是一组完整的工作代码,它们将生成我目前正在使用的图表。
library(networkD3)
nodes <- data.frame('name' =
c('Node0','Node1','Node2','Node3','Node4','Node5','Node6',
'Node7','Node8','Node9','Node10','Node11','Node12','Node13',
'Node14','Node15','Node16','Node17','Node18','Node19',
'Node20','Node21','Node22','Node23','Node24','Node25',
'Node26','Node27','Node28','Node29','Node30','Node31',
'Node32','Node33'))
links = as.data.frame(matrix(c(
0, 3,140,
0, 4,140,
0, 5,140,
0, 6,140,
1, 3,140,
1, 4,140,
1, 5,140,
1, 6,140,
2, 3,140,
2, 4,140,
2, 5,140,
2, 6,140,
3, 7,130,
3, 8,130,
3, 9,50,
3,10,50,
3,11,50,
4,12,140,
4,13,100,
4,14,100,
4,15,80,
5,16,150,
5,17,150,
5,18,60,
5,19,60,
6,20,180,
6,21,80,
6,22,80,
6,23,80,
7,24,13,
7,33,13,
7,31,104,
8,24,13,
8,33,13,
8,26,52,
8,27,52,
9,24,10,
9,33,10,
9,29,30,
9,30,30,
10,24,10,
10,33,10,
10,29,30,
10,30,30,
11,24,10, …Run Code Online (Sandbox Code Playgroud) 由于这个问题,我想将 6 个highcharter图表排成一行,就像这里一样。似乎在外面工作得很好flexdashboard
data(diamonds, package = "ggplot2")
diamonds <- diamonds[-6]
map(names(diamonds), function(x){
diamonds[[x]] %>%
hchart(showInLegend = FALSE) %>%
hc_add_theme(hc_theme_smpl()) %>%
hc_title(text = x) %>%
hc_yAxis(title = list(text = ""))
}) %>%
hw_grid(rowheight = 225, ncol = 3) %>% browsable()
Run Code Online (Sandbox Code Playgroud)
请在此处找到一个简单的示例,了解它如何在以下范围内不起作用flexdashboard:
---
title: "test"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
---
```{r}
library(highcharter)
library(data.table)
library(ggplot2)
library(htmltools)
```
### trying to render with hw_grid
```{r}
sliderInput('ncol','ncol',min = 1,max=4,value = 2)
``` …Run Code Online (Sandbox Code Playgroud) 我从Internet(链接)上找到了这张图片,我认为它是在R中绘制的。我试图重现此图,并使其与上面的链接中的图大致相似。我使用的代码如下:
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","Costo: 22808","Gastos directos: 6734","Gastos distribudos: 2958","Resultado: 8851","Total Gastos: 9332","Imp. Gcias: 3098","Resultado Netto: 5.753")
nodes <- data.frame(ID, name, NodeGroup)
nodes$NodeGroup <- as.character(nodes$NodeGroup)
source <- c(0:7, rep(8,9), 10:16, rep(9,3), 19, 20, 21, 21)
target <- c(rep(8,8), 17, 10:16, 9, rep(18,7), 19:21, rep(22, 2), 23, 24)
value <- c(29581,5279,4218,1917,1356,116,97,141,1714,17531,1744,1326,1208,526,459,14,18138,17531,1744,1326,1208,526,459,14,6374,2958,8851,6374,2958,3098,5753)
group <- c(1:8, rep(9,8), 10, rep(19,7), rep(18,3), rep(23,2), rep(22,2))
links <- …Run Code Online (Sandbox Code Playgroud)