【发布时间】:2016-01-05 13:42:42
【问题描述】:
我一直在尝试在我的 Shiny Project 中创建自定义图表,但出现错误:
> Warning in model.response(mf, "numeric") : NAs introduced by coercion
> Error in contrasts<-(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
> contrasts can be applied only to factors with 2 or more levels
代码如下:
observeEvent(input$create_cutom_graph, {
output$cutom_graph <- reactive(renderPlot(
plot(input$graph_X,input$graph_Y),
abline(lm(input$graph_X~input$graph_Y)),
title(input$graph_X,"i",input$graph_Y)
))
}
))
它应该工作的方式是你从下拉菜单中选择哪些数据应该在 X 轴上,然后你对 Y 轴做同样的事情,
然后您单击“创建”按钮,它可以解决问题,但不知何故它没有。
而且我还必须强调,我已经尝试在数据之前应用函数na.omit,例如:na.omit(input$graph_X),但它仍然不能解决问题。
谢谢你的帮助!
【问题讨论】: