Remember that for and while loops are slow in R. sapply/apply/lapply are better. You can always do:
sapply(1:n,FUN=function(i){...}). However, this does not always give great speed up if fundamentally your function is slow.
| apply | break | for |
| function | ifelse | invisible |
| mapply | next | repeat |
| return | sapply | stop |
| stopifnot | switch | tapply |
| warning | while |
| browser | debug | debugger |
| edit | fix | proc.time |
| recover | system.time | traceback |
Remember, x==expr is a logical vector, and if(x==expr) will only check if first element of that logical vector is true. Use any or all.
| all | all.equal | any |
| hasArg | identical | is.finite |
| is.function | is.infinite | is.na |
| is.null | missing | which |
| which.max | which.min |
| args | call | cat |
| complete.cases | eval | match.arg |
| on.exit | require | |