How to format plain text R code for Data Methods discussions?

Perhaps someone can give me a bit of guidance.

It is possible to execute R code without having to install it locally by doing a simple copy/paste at https://rdrr.io/snippets/.

I tried to do this in another thread, but there were some formatting errors when I tried to

  1. post the code here.
  2. then copy the code from here to the link above. It involves white space errors that mess up the syntax recognition of the online R interpreter.

The exact same code runs properly when I do a copy/paste from a text editor like Vim or Rstudio.

Is there a tag I’m unaware of that will permit plain text R code, that can be correctly copy/pasted? If so, I’d love to know it.

You should be able to highlight all the code and click on the “Preformatted text” icon or click Control-Shift-C to put code here that you can copy and pasted into that application.

2 Likes