The character "%" is used in an unusual way by the package "lubridate". Therefor the code detection fails. Example: d1= dat%m+% months(1) Error: Lexical error on line 14. Unrecognized text. 