小编Fah*_*bar的帖子

autoplot 不接受 ts 对象

我正在创建一个 ts 对象,然后我试图通过自动绘图运行它。执行给了我一个错误:

autoplot(pts, facets = TRUE) 错误:autoplot 不支持 mts/ts/matrix 类型的对象。

我已经检查了对象的类型,它是 ts 并且 autoplot 应该从 ts 对象中绘制一个图。我还尝试运行其他内置 ts 对象 (USAccDeaths) ,但它给了我同样的错误

图书馆(ggplot2)

pts <- ts(data = Popcopys[,-1], start = c(2006,1),frequency = 1)

autoplot(pts) autoplot(USAccDeaths)

预计会出现 TS 情节,但我得到的是这个错误:

autoplot(pts) 错误:自动绘图不支持 mts/ts/matrix 类型的对象。autoplot(USAccDeaths) 错误:autoplot 不支持 ts 类型的对象。

r ggplot2

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

Streamlit 小部件依赖性

我正在尝试两个小部件的简单概念,其中一个小部件依赖于另一个小部件

我希望用户单击一个按钮,打开一个数字滑块。然后,用户可以选择通过数字滑块选择数字。

这是我正在使用的代码

import streamlit as st
press_button = st.button("Press it Now!")
if press_button :
    # ask for the value
    th = st.number_input("Please enter the values from 0 - 10",)
Run Code Online (Sandbox Code Playgroud)

我面临的问题是,当我更改数字滑块的值时,streamlit 会重新运行整个过程,并且必须再次按下“按钮”才能返回到数字滑块。最终,数字滑块永远不会改变

python streamlit

4
推荐指数
1
解决办法
3634
查看次数

闪亮的R直方图

我正在使用以下代码来倾斜Shiny R,当我运行此代码时,它给了我这个错误:

警告:hist.default中的错误:默认值'x'必须为数字[没有可用的堆栈跟踪]

library(shiny)

ui <- fluidPage(
  selectInput("Ind","Indipendent Variable",choices = names(mtcars)),
  selectInput('Dep','  Dependent Variable',choices = names(mtcars)),
  plotOutput("BoxPlot"),
  plotOutput('Hist'))

server <- function(input, output, session) {

  data1 <- reactive({input$Ind})
  data2 <- reactive({input$Dep})

  output$BoxPlot <- renderPlot({boxplot(get(data2()) ~ get(data1()) , data=mtcars)})

  output$Hist <- renderPlot({hist(get(data1())}) 

}

shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

有什么帮助为什么会这样说?

r histogram shiny

2
推荐指数
1
解决办法
1478
查看次数

闪亮的 rhandsontable 对自身有反应

我正在尝试创建一个闪亮的应用程序,其中有一个rhandsontable。如果选择/检查另一列中的相应值,我希望 rhandsontable 能够更新其其中一列中的值。到目前为止,我已经能够使用反应/观察事件来更改两个对象之间的输出值,但我无法理解它,即,如何使 rhandsontable 的一列对同一个表中的另一列做出反应?

这是我正在尝试构建的一个简单示例:

library(shiny)
library(rhandsontable)

ui <- fluidPage(
  rHandsontableOutput('table')

)

server <- function(input,output,session)({

  data <- data.frame(c1=c(5,10,15), c2=c(3,6,9) , diff=c(0,0,0), select= as.logical( c(FALSE,FALSE,FALSE)))

  output$table <- renderRHandsontable({
    rhandsontable(data)
  })


}) 

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

因此,如果我检查“Select”列,“diff”列应该产生列 c1 和 c2 之间的差异

r shiny rhandsontable

2
推荐指数
1
解决办法
4928
查看次数

在 Shiny 中为表格的每一行选择输入

我有一个包含三列和可变行数的表。我想创建一个列,以便新列的每一行都包含一个值为 Yes/No 的 selectInput。

简而言之,我如何自动生成等于表中行数的 selectInput

这是一个简单的代码:

library(shiny)
library(rhandsontable)

ui <- fluidPage(

  tableOutput('Simpletable')

)

server <- function(input,output,session)({

  data <- data.frame(c1=c(5,10,15), c2=c(3,6,9) , diff=c(0,0,0), select= as.logical( c(FALSE,FALSE,FALSE)))


  output$Simpletable <- renderTable(
    data
  )

}) 

shinyApp(ui = ui, server = server) 
Run Code Online (Sandbox Code Playgroud)

对于这个表,三个 selectInputs 应该出现在表的旁边

这可能吗 ?

谢谢

r shiny

2
推荐指数
1
解决办法
1431
查看次数

标签 统计

r ×4

shiny ×3

ggplot2 ×1

histogram ×1

python ×1

rhandsontable ×1

streamlit ×1