ifelse with no else

前端 未结 2 1566
面向向阳花
面向向阳花 2020-12-30 07:32

Basically in SAS I could just do an if statement without an else. For example:

if species=\'setosa\' then species=\'regular\';

there is no

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 08:26

    I would recommend looking at the base R documentation for help with this. You can find the documentation of if, else, and ifelse here. For use of if and else, refer to ?Control.

    Regular control flow in code is done with the basic if and else statements, as in most languages. ifelse() is used for vectorized operations--it will return the same shape as your vector based on the test. Regular if and else expressions do not necessarily have those properties.

提交回复
热议问题