-1

Following this question, I wish to have some way of counting how many times I am using a package in my daily work.

Is there a function/package to do that?

In case there isn't, how would you construct such a capability?

The way I would do that is by changing it so that at the end of any R session, a log file of the commands would be saved to some location. On that file, I would grep out all instances of "library" and "require". Then save the results into a file (with some time stamp).

Lastly, I might want some function to (once in X time) send this file to a remote FTP location - so that other R users could analyse the results. (is there a way to do that with R ?!)

If someone wants to try and construct such a machanism - I'd be glad to help by providing a relevant FTP account and by spreading the word on it on "R bloggers" for the good of the community.

p.s (mainly for Shane): I wasn't sure if this question should go on stackoverflow or here. If this type of question wasn't debated yet on the meta.stat - it should be. If it was, I'll be glad to know what the conclusion of that discussion was.

Tal Galili
  • 19,935
  • 32
  • 133
  • 195
  • 1
    @Tal: I am basically happy to allow any R questions on here, but I just don't see how this has any relevance to the subject of data analysis. This is a meta question about R itself, not even about using R. We'll see what others think, but this seems more appropriate for stackoverflow, r-help, twitter, or a blog post. – Shane Sep 01 '10 at 16:12
  • Regarding how to do this: I would suggest making your own version of the `library` function that would track each package when you load it. – Shane Sep 01 '10 at 16:13
  • Related meta questions: http://meta.stats.stackexchange.com/questions/1/how-to-answer-r-questions and http://meta.stats.stackexchange.com/questions/169/is-it-possible-to-integrate-data-from-so-com-questions-tagged-r-here. – Shane Sep 01 '10 at 16:16
  • Lastly: regarding how to ftp; not sure how to do this from within an R function, but you can do it easily with `system("ftp ...")`. – Shane Sep 01 '10 at 16:20
  • Thanks Shane. I'll go through the threads. You are correct, this is more of a R community topic then a statistical one - I'll vote to close the question (I don't erase it since it is an example of a "bad" question for this website) – Tal Galili Sep 01 '10 at 16:56
  • Thanks @Tal. This is similar in nature to this question: http://stats.stackexchange.com/questions/2269/access-tables-created-in-sas-enterprise-guide-client-into-sas-enterprise-miner-cl, which was also closed. – Shane Sep 01 '10 at 17:00
  • You should also reach out to @johnmyleswhite: http://twitter.com/johnmyleswhite/status/22395563278 – Shane Sep 01 '10 at 17:03
  • 1
    If you were looking for gathering data on _installed_ packages, the crantastic package with its function crantastic.submitInstalledPackages would be worth looking at.. – Karsten W. Sep 01 '10 at 17:09

1 Answers1

3

Overload library() and require() so that they report what they do (whichever way: append to a text file, say) and have those replacement functions loaded first at startup.

Dirk Eddelbuettel
  • 8,362
  • 2
  • 28
  • 43