§2024-12-03

In R, both .r and .R can be used as file extensions for R script files, but .R is the more commonly used convention. Here's a breakdown:

  • .R: This is the preferred and standard convention for R script files. It is the most widely used extension for R scripts, especially when the file is intended to be recognized by IDEs, version control systems, or package managers. For example, if you're writing functions or scripts for a package, you would typically save them with a .R extension.

  • .r: While technically valid, this is less common. Some users might use this extension, especially on case-sensitive file systems (e.g., Linux) where file names are case-sensitive, but it is not the default or preferred extension in the R community.

In short, unless you have a specific reason to use .r, it’s generally better to use .R.

Return to Top