作为一个更大的应用程序的一部分,我生成了一个ANOVA,并使用输出来创建一个下拉列表,用于创建图。我有一个用于双向交互的下拉列表和一个用于三向交互的下拉列表。通过行名称中的冒号数找到交互作用。一个冒号表示双向交互,两个冒号表示三向交互,以此类推。
如果我使用这段代码,并选择仅双向交互,或双向和更高的交互,下拉菜单将按预期工作。完全相同的代码不工作,如果我选择了三种方式的互动。
下面的MRE用示例数据证明了这一点。如果您将模式匹配更改为>0,它将在下拉列表中显示所有交互,正如预期的那样。如果将其更改为==1,则如预期的那样,它仅显示双向交互。但是如果你把它改为>1或者==2,下拉列表就会中断,它会显示选项dataframe的名字,而不是选项本身。如果选择该选项,它将返回实际的选择,但不会在下拉列表中显示它。
我是不是做错了什么?
library(shiny)
library(dplyr)
# Define UI
ui <- fluidPage(
uiOutput("ems_int_sel"),
textOutput("selection")
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$ems_int_sel<-renderUI({
aov_l<-structure(list(Df = c(1, 1, 1, 1, 1, 1, 1, 72),
SS = c(0.199999999999973,0.112500000000021, 2.4500000000001, 25.3124999999997, 4.99999999999986,0.11249999999998, 1.07995057924757e-27, 13.9999999999996),
MS = c(0.199999999999973,0.112500000000021, 2.4500000000001, 25.3124999999997, 4.99999999999986,0.11249999999998, 1.07995057924757e-27, 0.194444444444439),
Fvalue = c("1.0286","0.5786", "12.6", "130.1786", "25.7143", "0.5786", "0", ""),
Pvalue = c("0.3139", "0.4494", "7e-04", "<0.0001", "<0.0001","0.4494", "1", ""),
Sig = c("", "", "***", "***", "***","", "", ""),
EMS = c("Error+40atm", "Error+40rzt", "Error+20atm:rzt","Error+40salt", "Error+20atm:salt", "Error+20rzt:salt", "Error+10atm:rzt:salt","Error")),
class = "data.frame",
row.names = c("atm", "rzt","atm:rzt", "salt", "atm:salt", "rzt:salt", "atm:rzt:salt", "Residuals"
))
req(aov_l)
int_sel<-data.frame(rownames(head(aov_l,-1)))
int_sel<-filter(.data = int_sel,str_count(string = rownames(head(aov_l,-1)),pattern = ":")>0)#change this 0 to a 1 and the choice does not appear
names(int_sel)<-"Interactions"
disp<-TRUE#logical True is a dispersion test
if(disp){
int_title<-"Show Three-Way Interaction Plots for Dispersion:"
} else{
int_title<-"Show Three-Way Interaction Plots for Means:"
}
selectInput(inputId = "ems_int_selected",
label = int_title,
choices = int_sel,
multiple = TRUE,
width = "100%"
)
})
output$selection<-renderText({
input$ems_int_selected
})
}
# Run the application
shinyApp(ui = ui, server = server)
1条答案
按热度按时间ecr0jaav1#