require(shiny)
setwd("C://Users//Harshad//Desktop//Equiskill - BA")
cars <- read.table(file = "cars.csv", sep = ",", header = TRUE, quote="")
var_list <- as.character(names(cars))
ui <- fluidPage
(
selectInput(inputId = "var",label = "Select Dependent Variable:",choices = c(var_list))
)
server <- function(input,output)
{
}
shinyApp(ui <- ui, server <- server)
我收到错误“错误:在R studio中执行上面闪亮的应用程序代码时,不能强制类型'字符'的向量类型'环境'。请帮我解决这个问题。
答案 0 :(得分:3)
您应该避免在函数名称后添加newlines
甚至spaces
。请参阅style guide或here。下面的代码完全正常。
require(shiny)
# load your data I am using default mtcars data here
cars <- mtcars
var_list <- as.character(names(cars))
ui <- fluidPage(
selectInput(inputId = "var",label = "Select Dependent Variable:", choices = c(var_list))
)
server <- function(input,output)
{
}
shinyApp(ui = ui, server = server)