小编var*_*nna的帖子

如何根据从 R 中另一个数据帧提取的列名在 Plotly 中绘制 a

我有两个示例数据框,如下所示

library(shiny)
df1 <- data.frame(words = c("bat", "vat","cat","mat"), count = c(3420, 2098, 2003, 1501), words_count = c("bat (3420)","vat (2098)", "cat (2003)", "mat (1501)"), stringsAsFactors = FALSE)

df2 <- data.frame(class = c("A","B","C","D"), bat = c(10,0,30,20), vat = c(0,0,10,30), cat = c(20,30,0,10), mat = c(20,20,0,0), stringsAsFactors = FALSE)
Run Code Online (Sandbox Code Playgroud)

使用下面的代码,我想从下拉菜单中提取列名称(由 df1 制成),并使用提取的值在绘图中绘制条形图,使用提取的值作为 df2 中的列。我正在做这个是 Rmd。

inputPanel(
  selectInput("words", label = "Choose the word",
              choices = df1$words_count, 
              selected = df1$words_count[1], width = '100%')
  )

renderPlot({
# Extract the word from drop down
  col_word <- df1 …
Run Code Online (Sandbox Code Playgroud)

r dplyr plotly

5
推荐指数
1
解决办法
1261
查看次数

有没有办法在出现某些提示后停止“是”命令

您好,我有一个脚本,需要用户输入 4 个“是”,而第 5 个提示需要一个数字。

有没有办法在 4 个“是”之后停止 yes 命令,以便用户可以在第五个提示中输入数字。

bash

0
推荐指数
1
解决办法
1505
查看次数

标签 统计

bash ×1

dplyr ×1

plotly ×1

r ×1