I am writing my first R package, converting my existing scripts into a bona fide package. I frequently use the magrittr pipe operator %>% in my code because I find it makes code more intuitively readable and saves typing. However, in order to use this pipe in the code of an R package, I would need to force all users of my package to install the magrittr package via Imports. Is this a reasonable thing to do, or should I re-write all of my R scripts avoiding the use of the pipe operator?

  • This question has received 2 upvotes and 1 downvote. Could the person who downvoted please comment as to why, so that the question can be improved? Thanks. – Josh May 1 '19 at 15:27

In general, it is completely up to you - the creator of a package - to define your package's dependencies. Ultimately you are saying to future users of your package: you must be willing and able to use these dependencies, or otherwise you will not be able to use this package.

You may decide to be as minimalist as you like, or you can require so many arcane and difficult to install libraries to be used that only the most die-hard and motivated soul would be willing to bother with your contribution at all (there is certainly more than a few such bits of software floating around!). Some of the specialized libraries in computer vision and neural networks might be an example - you wouldn't want to require them if you didn't really need them for your package.

The reasonable in-between is saying, "do these dependencies put much of a burden on people who I want to be able to use my software?" If the answer is "not nearly as much of a burden as it would be for me to not use these libraries myself", then there you go - include away, that's literally what they are there for!

The burden of needing to use extremely common libraries is generally less, as you expect most users have already installed it or will be installing it for their own uses anyway (and magrittr is pretty popular in the R world, so I'd be more concerned with packages that you have found difficult to find and install successfully).

If this were part of a large project or one with very specific hardware/software limitations, I would implore you to collect requirements on what sort of systems, operating systems, and versions you must support. Then you need only compare your considered dependencies to the requirements you have collected. If you don't have these limitations, yay - you can just focus on your own productivity as a developer and use what helps you get your work done.

  • That makes a lot of sense. This is my first post to SE.SE. Should I accept your answer, or hold off to allow for "debate"? – Josh Apr 26 '19 at 4:43
  • 1
    @Josh some people like waiting a day before choosing the best answer. But if this one resolves your problem you are perfectly free to accept it. Should another answer be posted you can change your mind later. – amon Apr 26 '19 at 5:31

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.