1

Is there a way to turn off/on echoing to the R console (without using source()?)

For example, let's say I have a long .R script and I wish to run only one line from it. Say that line is x <- 9.

In RStudio, I can go to the line in question and use the "Run Selected Line(s)" command from the "Code" menu (or keyboard shortcut ctrl-enter on my PC). What'll happen upon doing that is it the console will print x <- 9 (and then obviously, R will create a variable called x and assign it the value 9).

Is there a way to not have this line echoed in the console (but still create the variable)?

The reason I ask is that I have lengthy lines of code that just define functions and every time I want to update a function, it echoes the whole thing to the console, and that burns a lot of time.

Thanks.

user1713174
  • 307
  • 2
  • 7
  • Is running in the command line like [here](https://stackoverflow.com/questions/17796716/how-can-i-avoid-having-my-r-script-printed-every-time-i-run-it) OK? – Rui Barradas Oct 13 '20 at 20:02
  • 1
    Commands only actually run in the console. The editor needs to copy everything there in order for it to actually run. So it's not that the command is being echoed, it's that it's actually running. You need to actually send the commands to R somehow. How big is your function that it takes a long time just to create it? How come you are changing it so often? Is it possible to change the function so it has parameters for the things that are changing? – MrFlick Oct 13 '20 at 21:04

0 Answers0