Shiny:server中的if else语句.R具有意外符号

时间:2015-11-11 15:10:49

标签: r shiny

我在R中使用以下代码,在我的闪亮应用程序中评估它时会抛出“意外符号”错误。

output$CHOresult <- renderText({
  CHOdiff = CHOdiff(CHOsum = input$mass, CHOgoal = input$height)

  if      (CHOdiff <=  0.05) info = "<span style='color: green'>you do not need to add more carbohydrate.</span>"
  else    (CHOdiff > 0.05)   info = "<span style='color: red'>please add more carbohydrate.</span>"

  paste0("The carbohydrate in this meal is ", "<code>", round(CHOdiff, 2), "</code>", "grams away from the goal,", info)
})

错误消息表示错误发生在第二个info

Error in source(file, ..., keep.source = TRUE, encoding = checkEncoding(file)) : 
  unexpected symbol
253:   if      (CHOdiff <=  0.05) info = "<span style='color: green'>you do not need to add more carbohydrate.</span>"
254:   else    (CHOdiff > 0.05)   info
                                  ^

我认为我的if else声明是有效的。显然它不是。有什么想法吗?

0 个答案:

没有答案