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


will return a syntax error.

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


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.

About Richard Telford

Institutt for biologi

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.