R语言中if else语句的编写格式

因为R是解释语言,如果else单独起一行,无法解释执行。

所以else不能单独一行,最好这样写:

if(a) {
    print("hello")} else {
    print("Hi")}

相关文章: