2

I have a simple R Project. When I create a new project it opens up a window with the title script.R. I type in a simple 3 line script that runs without error in the interactive window but when I "rebuild all" I get

MSB4057 The target "rebuild" does not exist in the project.

If I simply build the project and debug it works fine. Apparently "rebuild" needs to be added to the R project template or taken away from the build menu. Also when I do a build the script.R is not automatically saved.

Mike Wise
  • 22,131
  • 8
  • 81
  • 104
Kevin Burton
  • 133
  • 1
  • 1
  • 8

1 Answers1

5

R projects are not buildable since R is not a compiled language. They are interpreted by the R engine each time you run the code.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • I understand that. But I can run "debug" and set breakpoints at specific lines in the script as long as I have VS installed. Is there anyway to package up the script, R packages that are used, and the R engine itself and run that irrespective of VS? Like JavaScript. I can put some code together and debug in with VS and then "deploy" so I am not dependent on VS even though JavaScript is also an interpreted language. – Kevin Burton Dec 05 '16 at 13:29
  • Of course. R project is simply reflection of file structure on disk. Project file is not required, it is used mostly to store some settings. Simply copy all files to another machine, install R engine, then required packages via install.packages() (you can write R code that will automate this) and run the code. You (or your co-worker) can also open same folder in RStudio and work there or copy files to Mac or Linux. RTVS does not tie you to Visual Studio. – Mikhail Arkhipov - MSFT Dec 06 '16 at 17:25
  • I would be interested in seeing this R code for automated package installation. If the project starts to use the custom VS packages (like Revo...), do you know how to install those? – Kevin Burton Dec 07 '16 at 21:13
  • Basically you write R file with a number of statements like 'install.packages("mypackage1")' then source it. – Mikhail Arkhipov - MSFT Dec 08 '16 at 23:34