【发布时间】:2012-07-04 09:12:03
【问题描述】:
我有一个 if 条件,后面跟着几个命令。但是,似乎存在语法错误并且无法正常工作。我想这很容易。我四处寻找正确的医生,但没有找到解决方案。感谢您的帮助!
#data
supply_by_gas <- rep(0,365)
supply_by_gas[] <- 32069547/365
overall_gas_prod <- 51224298
#here the condition which should be true
if (overall_gas_prod > sum(supply_by_gas))
#followed by two commands
{peak_use_gas <- (overall_gas_prod - sum(supply_by_gas))
overall_gas_prod <- sum(supply_by_gas)-1 }
else
{peak_use_gas <- 0}
这是我收到的错误:
Unexpected 'else' in "else"
> {peak_use_gas <- 0}
【问题讨论】:
标签: r if-statement command