3

I am a data scientist and do lots of programming in R/RStudio.

I like to be organised (as I'm sure (hope) most programmers do) and as such I always use the Project feature in RStudio to keep my work organised so that I can comfortably switch between projects in just a couple of clicks, keeping related files together.

Due to the nature of my work, I regularly (daily) receive queries from colleagues about ad-hoc/random things that they wish to know about.

How I initially handled this was to write some code randomly, in the middle of my current script (yes, I know) in order to give them their answer, and then erase the code.

However, sometimes I simply forgot to remove the code due to distractions (we're all human) and it occasionally caused me to spend a bit of time analysing my code to detect where the error(s) occurred and rectify the problem.

As I found this to be a common problem (for me, at least), I decided to set up a Miscellaneous R project for all such requests - I can simply switch to that project, script/calculate the person's request, give them the answer and then return to my other project. This removed the risk altogether of me negatively affecting existing projects and furthermore, I found that having a Miscellaneous project also allows me to test code/models that I have built without it disrupting anything in any existing project workspaces.

I have searched online for advice around such things, and what the common approach to this is, but haven't found anything useful.

As such, my question is this: is creating a Miscellaneous project for ad-hoc requests considered good practice? If not, what is the better/best way to handle such scenarios?

  • Look into a version control system and then you can just put ad hoc requests on a different branch – Robbie Dee Jul 12 '18 at 12:05
  • I did consider this, actually; however, the only reason I thought that it might not be the best option for me in this scenario is because the ad-hoc requests never relate to any existing projects that I am doing, so that is why I thought that a new project might be the better solution. Do you think a branch would be better? What benefits would creating a new (unrelated) branch have over a separate project? – MusTheDataGuy Jul 12 '18 at 12:09
1

I'm not an R developer, but I do get requests like this. Also, I sometimes found the need to test out a small piece of code on its own. I tend to make small projects in Visual Studio for this.

The problem with that has been that I would lose track of what snippets I have lying around. To overcome that, I've made it a habit of spending time every now and then, going through these snippets and collecting the things I might want to use more often. I'd put these in different little tools that I might use on customer projects, or end up putting them in a library that I can reference from another project.

What it comes down to is this. Put snippets of code in a toolbox so that you can reuse them when needed.

1

I do something similar, and have done so in the past at other companies. I often want to test out some aspect of C# / .Net. I keep a separate Visual Studio project that contains a variety of test files. When I need to test I start up Visual Studio on that project and add a file. Works quite well and has the added benefit that I can keep that project and refer back to it.

This keeps everything tidy, and you can refer back to that project if someone asks how you got some results or wants a modification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.