Shiny 闪亮应用程序中的动态方差分析,我的输入是否错误?
这段代码运行良好。但当我只使用factor(input$mtcarsid)时,我得到一个错误,输入的长度不同(1对32) 一种解决方案是将所选变量转换为aov()调用之外的因子Shiny 闪亮应用程序中的动态方差分析,我的输入是否错误?,shiny,anova,Shiny,Anova,这段代码运行良好。但当我只使用factor(input$mtcarsid)时,我得到一个错误,输入的长度不同(1对32) 一种解决方案是将所选变量转换为aov()调用之外的因子 输出$model data(mtcars) library(stats) library(shiny) # Define UI for application that draws a histogram ui <- fluidPage( # Application title titlePanel
输出$model
data(mtcars)
library(stats)
library(shiny)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectizeInput("mtcarsid", "Nehme eine MT Cars category.", choices = colnames(mtcars), selected = colnames(mtcars)[2], multiple = FALSE)
),
# Show a plot of the generated distribution
mainPanel(
tableOutput("model"),
textOutput("text123")
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$text123 <- renderText({
})
output$model <- renderTable ({
z <- factor(input$mtcarsid)
# #print(mtcars[[z]])
#
# print(length(mtcars$mpg))
#
# print(length(mtcars[[z]]))
x <- aov(mpg ~ factor(mtcars[[z]]), data=mtcars)
x <- TukeyHSD(x)
print(x)
x <- as.data.frame(x[[1]][,4] > 0.05)
x
})
}
# Run the application
shinyApp(ui = ui, server = server)
aov(mpg ~ factor(cyl), data = mtcars)
output$model <- renderTable ({
mtcars[["selected"]] = factor(mtcars[[input$mtcarsid]])
x <- aov(mpg ~ selected, data=mtcars)
x <- TukeyHSD(x)
print(x)
x <- as.data.frame(x[[1]][,4] > 0.05)
x
})