What to do with imperfect-but-useful functions?

前端 未结 3 1145
南笙
南笙 2021-02-13 12:56

I could equally have titled this question, \"Is it good enough for CRAN?\"

I have a collection of functions that I\'ve built up for specific tasks. Some of these are co

3条回答
  •  暖寄归人
    2021-02-13 13:39

    In my opinion it is not a good idea to make this type material into packages.
    Misc-packages do exist, but mostly for historical reason and/or due to their authoritative contributors, see Frank Harrell Hmisc .

    I see three main reason why this choice does non fit for disparate collection of functions.

    1. There are by and large 7000 packages on CRAN only. It is unlikely that your package will be chosen if it does not target a specific field and, even when this happens, it is very possible that other established packages do the same. Therefore your package should also sport an original/better solution to the problem it deals with.

    2. Repositories, and CRAN in particular, are task-oriented, which suggests packages' functions should address a coherent task. And for a good reason: there is no point in downloading a whole package with say, 50 autonomous functions, when I need just a couple of them. Instead, if a package solves a specific data problem of mine, than I will most likely need most (if not all) of them.

    3. R repositories tend to mask the content. Contrary to tech blogs, you do not immediately see the functions' source. You need to download a separate source package and there is a lot of overhead due to the package structure, which buries the actual functions you are willing to show and the others need to read.

    In my opinion the best place for general convenience functions, are sites like GitHub. In fact:

    1. One immediately reads them with the comfort of syntax highlight. If they are interesting, they can be pasted in R to give a try and possibly keep them, otherwise one simply steps over to read next function.

    2. There is the possibility of organising code, but without all the constraints of an actual package. Similar functions might go in the same file and coherent files in the same subfolder.

    3. You can show your ideas to the others in a simple way. The readme file can immediately become a sort of mini webpage (via markdown). In comparison CRAN is quite rigid.

    There are a lot of other benefits (revision history, accepting contributions, GitHub pages), which may or may not interest you.

    Of course, after several functions grow in a stable coherent direction, you will turn them into an actual CRAN package. Also because the copy and paste method to try them becomes then inconvenient.

    EDIT: Nowadays there are alternatives to GitHub, which can be taken into consideration too and GitHub has become a common way to distribute packages not yet ready for CRAN or to integrate the official CRAN distribution page.

提交回复
热议问题