Q:

Why is only 1==TRUE, true, in R and other numbers are false?

What happens if an if() statement doesn’t contain a logical expression? 
For example, the if-else block if(2){print("A")}else{print("B")}) outputs A, but 2 is not true so it should print B. Why?

A:

It is because any value other than 0 would be coerced to TRUE while 0 will be FALSE in the if
if(2){print("A")}else{print("B")}
#[1] "A"
if(1) print("A")
#[1] "A"

if(0) print("A") else print("B")
#[1] "B"

It can be checked with as.logical
as.logical(c(0, 1, 2, -1, 5, 3))
#[1] FALSE  TRUE  TRUE  TRUE  TRUE  TRUE

Here the TRUE will be mapped to 1 and FALSE to 0 (binary) and if can have only two cases either TRUE or FALSE.

There was another question in the title and that was why 1== TRUE.  The reason is that TRUE/FALSE is internally 1/0. So, 1 gets coerced to TRUE or TRUE to 1 during the == while other numbers remains as such

