Starting off as a muggle that naïve to the Math's and Data Science world.

Day 5 (2)

Condition

==,<,<=,>,>=,!= boolean operators


if/else

if(1>2){"large"}else{"small"}
ifelse(1>2,"large","small")

Result:


switch if not integer/index, must define result.

switch(1,"one","two","three")

Result:

out of condition return NULL

switch("d","a"="apple","b"="boy","c"="cat")

Result:


for

for ( i in 1:3 ){ print(i) }

Result:


while

i = 1
while ( i < 4 ) { print(i); i=i+1; }

Result:


repeat

i = 1
repeat { print(i); i=i+1; if(i > 3) break; }

Result:

Leave a comment