Skip to content

Example Syntax for if - then- and - else Statements

1 message · Lanre Okusanya

#
Hello R users,

I am a fairly new R user, however, one of the problems I am having is 
the use of applying if-, and-, then-, else- statements in R against 
datasets & dataframe. Rtips mentions it, but without simple examples I 
am not quite sure what my syntax should look like. I am particularly 
interested in syntax that can be used with the transform function. for 
example

    if foo[,1] == 'n', foo[,2] == 4, else foo[,2] == 6

Could someone please share simple example codes with different variants 
on the theme.
thanks.