R Project Workflow - Understanding

Hello,
Just to make sure, my understanding is that there are 4 different options to write code in R in RStudio:

  1. Type code interactively in the console
  2. Create a R script (Extension .R)
  3. Create a R notebook (extension .rmd)
  4. Create a R markdown doc (extension .rmd)
  5. Create a quarto doc (extension .qmd)

I am slightly confused about options 3. , 4. , 5. They all seem very very similar in the final output. Is that a correct? I believe the quarto doc markdown is slightly different from the R markdown syntax...I just don't appreciate the different options...Should I stick with creating R notebook? Both R notebook is R markdown are files with the same extension .rmd

The best way seems to start a new project (which is equivalent to simply creating a folder) for each, obviously different type of project and create docs that will then get automatically saved in that project folder...

Thank you,

Yes, basically they all produce the same type of output. Notebooks was an attempt to emulate the behavior of Jupyter notebooks, they are basically an RMarkdown file with live preview rendering on save, the preview rendering has low resolution but renders faster.

Quarto is a broader take on literal programming that is not mainly focused in R like RMarkdown is, Quarto is an independent software that supports several languages like R, Python and Julia and it is going to be the way forward from now on.

This is an oversimplification, a project has its own configuration options, an isolated working environment and output cache among other things.

1 Like

Thank you andresrcs.

Would it be correct to think of creating a project as being equivalent to creating a virtual environment in Python, which is not just a simple folder but something where a specific version of Python interpreter, along with all files and dependencies about a specific project, are saved and isolated from the rest to avoid conflicts of all sorts?

I read that using New Project is the best most current practice instead of creating a regular folder and using the function setwd() to change the working directory so everything pertaining to a project gets saved in a specific folder....Would you agree with that?

Thank you

Not out of the box, and not to that extent. You can choose to enable renv when you create a project which creates a project-level package library but it doesn't allow for independent R versions.

I think there is no native solution for that in R, some people use virtual envs, although, integration with the R ecosystem is not seamless and other people use containers which might be an overkill when you are simply exploring an idea and not making a "production" ready data product.

Yes, using projects is a better workflow in most cases.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.