18. Strings
> a = "ORION"
> a
[1] "ORION"
> substring(a,2,4)
[1] "RIO“
> nchar(a)
[1] 5
19. if-then/else
>if (a==50) date()
[1] "Wed Jun 11 01:03:14 2014"
> a = 110
> if (a > 100) "Greater than 100" else " Not greater than 100 "
[1] "Greater than 100"
> a = 50
> if (a > 100) "Greater than 100" else “Not greater than 100"
[1] "Not greater than 100"
20. for loop
> a
[1] 1 2 3 4
> s = 0
> for(i in a)
+ s = s + i
> s
[1] 10
21. switch
> i = 2
> switch(i,"I","II","III")
[1] "II"