0

I want to make a generic script in which user can run all my r code in console with single click

My some R code

nil_sal_log_sqldf = sqldf("Select psno, name , unit , DOS, Field_description , log_new_value , MAX (inserted_on) as INSERTED_ON from test group by psno having log_new_value = 'Yes' ")

and many more code like this

Right now user have to copy my code and run it on console

is there any way that he can run my whole code with singe click

sana
  • 15
  • 6
  • 1
    Click? In console you type, there is no clicking if I am not mistaken – Shique Apr 25 '18 at 09:47
  • What editor are you using ? The classical Rgui ? – Stéphane Laurent Apr 25 '18 at 09:52
  • R studio, using console – sana Apr 25 '18 at 09:53
  • is there any way like we use in shell script, put all your code in script and then save file and then run the file. is there anything like this in R – sana Apr 25 '18 at 09:54
  • Maybe you are looking for this: [*Run R script from command line*](https://stackoverflow.com/questions/18306362/run-r-script-from-command-line) ? – Jaap Apr 25 '18 at 10:15
  • Are you using Rstudio? Because if you are sharing your .Rmd file, there is a button for doing just what you want to accomplish. But if you want to save the R code in your markdown file into an R script, you can try `knitr::purl`. – hpesoj626 Apr 25 '18 at 11:02
  • Ctrl + Alt + G in RStudio will prompt for a source code file which is then executed using `source(...)` – G. Grothendieck Apr 25 '18 at 16:43

1 Answers1

0

If you are working in R Studio, you should probably be able to click "File" -> "New File" -> "R Script". That should open a separate window in which you can type all your code, and you can save that script and run it at a later time after reopening.

For example you could use CTRL+ALT+B to run all code in the script from beginning until the current line.

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
Lennyy
  • 5,932
  • 2
  • 10
  • 23