370466 (1) [Avatar] Offline
#1
How come in line 3 comment says "if is.employed==TRUE" and actual code says "ifelse(custdata$is.employed==T

So why can you just put T instead of TRUE? Data has TRUE.
john.mount (79) [Avatar] Offline
#2
In R TRUE, FALSE are the actual values, and T/F are "shortcuts" that map to the values TRUE,FALSE (think of them as system variables with values T=TRUE,F=FALSE). So "(7==7)==TRUE" and we also have "(7==7)==T" (unless somebody comes in and assigns a new user variable T with a different value!).

So we could have written any of "ifelse(custdata$is.employed==T,...,...)", "ifelse(custdata$is.employed,...,...)", or "ifelse(custdata$is.employed==TRUE,...,...)". The extra "==" in the first and third form serve no purpose in the executing code, but make it more obvious when reading we are checking a value (like "ifelse(x==7,...,...)").

However, we now don't recommend using the aliases T/F (due to the danger of somebody messing them up with a line like "T <- 7").