codeRclub | bioCEED R coding club

Oct/15

26

Avoid using T to mean TRUE

In R code, it is legal to use T and F to mean TRUE and FALSE respectively. However, TRUE and FALSE are reserved words – they can only be used to mean TRUE or FALSE. Code like

TRUE<-7

will return a syntax error.

T and F are not so protected. This means that code like

T<-FALSE

is completely legal.

Of course, you wouldn’t deliberately do this (except perhaps at the start of April), but it is possible to do it accidentally. Perhaps, for example, a column of a data.frame is named T or F and you have attached it. It is best to be safe and always use TRUE and FALSE. This also makes code easier to read.

No tags

No comments yet.

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me