我'尝试通过插入pch
的输入来修改plot
的{{1}}参数:
selectInput
到
selectInput("points", "Points:",
list("Job lost" = "joblost",
"Sex" = "sex",
))
不幸的是,我收到了一个错误:无法强制类型'关闭'到'' double'类型的向量。我应该采取什么措施来解决这个问题?当然,工作和性别都是因素。 完整代码:
output$Plot <- renderPlot({
plot(as.formula(formula()),data=Benefits,
main = caption(), pch = as.numeric(input$points),
col=as.numeric(input$points))
})
答案 0 :(得分:0)
使用selectInput
中的开关
pkt <- reactive({
switch(input$points,
"Powod utraty pracy" = joblost,
"Plec" = sex,
"Nie-bialy" = nwhite,
">12 lat szkoly" = school12,
"Robotnik fizyczny" = bluecol,
"Mieszka w miescie" = smsa,
"Zonaty" = married,
"Ma dzieci" = dkids,
"Male dzieci" = dykids,
"Glowa rodziny" = head,
"Otrzymuje zasilki" = ui)
})
txt <- renderText({paste(input$points)})
output$Plot <- renderPlot({
plot(as.formula(formula()),data=Benefits,
main = caption(), pch = as.numeric(pkt()),
col=as.numeric(pkt()))