0
當我運行Shiny應用程序時,我無法獲得「random_comment」,「best」或「worst」數據。有人能指出我正確的方向嗎?閃亮的多輸出
我ui.R文件
# This Shiny app will allow users to upvote/downvote my teaching evaluation
# comments on the basis of how "useful" each comment is
library(shiny)
shinyUI(fluidPage(
headerPanel("Rate my Teaching Evaluations!"),
mainPanel(
h4("The current comment:"),
random_comment,
tabsetPanel(
tabPanel("About",
"...",
paste("Currently there are", m, "comments in the dataset.", sep = " ")
),
tabPanel("Most Useful Evaluations", tableOutput("best")),
tabPanel("Least Useful Evaluations", tableOutput("worst"))
)
)
))
和我server.R文件
library(shiny)
shinyServer(
function(input, output){
studentsSay <- readLines("studentsSay.txt")
output$m <- length(studentsSay)
evalDF <- data.frame(studentsSay, rep(0,m))
colnames(evalDF) <- c("comments", "rating")
output$random_comment <- as.character(evalDF[ sample(1:m, 1), "comments"])
output$best <- renderTable({head(evalDF[ order(evalDF$rating), "comments" ])})
output$worst <- renderTable({tail(evalDF[ order(evalDF$rating), "comments" ])})
}
)
我嘗試過的一些的反應功能,如renderText和renderTable,但我仍然不看到輸出。