Here are a few related questions from the meetup, Meetup: Making the Shift from Excel to R: Perspectives from the back-office
It'd be great to hear your thoughts in the comments below as well!
Are you suggesting that all our code be written in R Markdown and when do you use R scripts?
Mandip: I use regular R scripts as part of a larger process if I’m bringing in a whole lot of data for a trading application but will typically start off in an R Markdown document. Sometimes the team will come back to me to ask for this in a script for x, y, z reason. Whether or not that’s good practice, I wouldn’t be able to comment on that.
Why would you want to move an R Markdown to a script?
Mandip: Take for example, as a business analyst, part of my job is to write up requirements for a developer to put something into production. I would start by writing in RMD, explaining the logic, explaining where I’m coming from but at some point, my code might not be as efficient for putting this into production. That was their particular preference of how I do that.
Are you suggesting that all our code be written in R Markdown and when do you use R scripts?
Tony: Perhaps it would be helpful to put that into a package. When I’m developing, everything gets made into a function which gets made into a package. My script even if I have to share it is a single line that says to run this function which is composed of other functions.
Mandip: That’s a very valid point. At our organization, we’re not at that point yet but I might try to implement that
Why would you want to move an R Markdown to a script?
Vasant: I have a point to add to that. In some cases, you might want to run this at a command line or give it as an executable to a vendor. We do that in the biology lab, I make a command line script so people can just import whatever data they have. They don’t want to necessarily install R, install a package, or deal with any of that and that’s an easy way to push things into production as well. If you want to have a bunch of scripts in your pipeline, I do that a lot where we use little R (package) so that you can use an r script as an executable. If it’s going to get more complicated, definitely use a package because that way you can document it, have help, have functions documented but that’s one example where you might not want to have a package. As Mandip said, I’ll start the RMD and then knit the script from that, make it an executable and use that.