小编ros*_*er9的帖子

通过Shiny ggplot中的点击创建数据集

我是一个闪亮的新手,但是我正在尝试将其用于我正在从事的项目中。我希望能够通过单击ggplot图上的一个点来做两件事:在指定点添加绘图字符(以侧边栏中的信息为条件),并将坐标(带有侧边栏中的信息)添加为一个数据帧。到目前为止,这是我在代码方面得到的:

library(shiny)
library(ggplot2)

df = data.frame()


ui = pageWithSidebar(
  headerPanel("Test"),

  sidebarPanel(
    radioButtons("orientation", "Pick", c("L", "P", "H")),

    selectInput(
      "select1",
      "Select Here:",
      c("Option 1", "Option 2")
    ),

    selectInput(
      "select2",
      "Select Here:",
      c("Option 3", "Option 4"),
    ),

    radioButtons("type", "Type:", c("P", "S")),

    radioButtons("creator", "Creator?", c("H", "A"))
  ),

  mainPanel(
    plotOutput("plot1", click = "plot_click"),
    verbatimTextOutput("info"),
    actionButton("update", "Add Event")
  )
)

server = function(input, output){

  output$plot1 = renderPlot({
    ggplot(df) + geom_rect(xmin = 0, xmax = 100, ymin = 0, ymax = 50, fill = "red")
  })

  output$info …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 shiny

3
推荐指数
1
解决办法
562
查看次数

如何在Shiny中创建倒数计时器?

I'd like to be able to create a countdown timer (example: 20 minutes and then the timer beeps) for an R Shiny app that I'm working on that the user can start, stop, and reset by clicking start/stop/reset buttons. I've seen a few examples of countdowns that count towards a specific date/time, but haven't come across one for a generic timer. Is something like this possible? Any help would be appreciated!

r shiny

3
推荐指数
1
解决办法
1237
查看次数

如果元组的元素不在字符串列表中,则从元组列表中删除元组

我正在处理一些代码,如果元组在单独的列表中未包含所有字符串,则需要从元组列表中删除元组。我已经在for循环中使用了它,但是我正在尝试提高代码的效率。例如,如果我有

list_of_tups = [('R', 'S', 'T'), ('A', 'B'), ('L', 'N', 'E'), ('R', 'S', 'T', 'L'), ('R', 'S', 'T', 'L', 'N', 'E')]
needed_strings = ['R', 'S', 'T']
Run Code Online (Sandbox Code Playgroud)

我想将以下元组保留在列表中:

[('R', 'S', 'T'), ('R', 'S', 'T', 'L'), ('R', 'S', 'T', 'L', 'N', 'E')]
Run Code Online (Sandbox Code Playgroud)

这适用于以下for循环:

for s in needed_strings:
    for tup in list_of_tups:
        if s not in tup:
            list_of_tups.remove(tup)
Run Code Online (Sandbox Code Playgroud)

但是,我希望通过列表理解来完成。我尝试这样做的结果是产生一个元组列表,其中任何字符串(不是全部)都出现在元组中。

python list-comprehension

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

标签 统计

r ×2

shiny ×2

ggplot2 ×1

list-comprehension ×1

python ×1