Dear R colleagues, is there an easier way to write R packages for the own use - without RTools and TeX? With R versions < 2.10.0 it was very easy to write a package. Under the path with the package name you wrote a description file and built some directories like "help", "html" and "R" with the special files in a "hand-operated" way. In the next step I constructed the MD5 check sum file with a program like "md5summer". Packing the directory with a zipper - and the package work was finished. Ok, this was not the official way. And now (R versions > 2.10.0) this method will not be successful and R doesn't accept those packages. But just for me the official rules writing a package cost a lot of time if I look to the result I get. My functions are very specific and have something to do with several computers I use. So I have not the intention to upload this package to CRAN. From the point of the costs e. g. I had to learn writing help files in a TeX-like language. But I'm the typical Word user. My last TeX writings were done in the 1990s! If I'm changing only a letter in a source file (r-file or help file) I've to build a new package. Seeing the results in my eyes this is a very expansive way. It's easier to me to write those files in HTML and to change the HTML source code. I don't need help files in Rd format. Does anyone know a easier way? If not just a question to the members of the R Development Core Team: Could you imagine to open an alternative way of writing packages? Is it possible to that new versions of R will again accept the build of packages like in R versions < 2.10.0? Don't misunterstand me: I absolutely agree that R packages which should become part of CRAN must obey to official rules like described in the manuals. But I think you can controll this while uploading a package to CRAN. In my eyes an alternative, easier way writing a R package would help first-time users and typical MS Word damaged people like me. Thanks for your help in advance! Greetings from Muenster/Germany Dr. Michael Wolf (E-Mail: m-wolf at muenster.de)
On Fri, Feb 11, 2011 at 7:52 AM, Dr. Michael Wolf <m-wolf at muenster.de> wrote:> Dear R colleagues, > > is there an easier way to write R packages for the own use - without RTools > and TeX?There are simpler ways of maintaining R source code than building packages. I bashed out a quick way of keeping code in directories as source and reading in on demand. All you need is two functions: import <- function(dir){ e = attach(NULL,name=dir) assign("__path__",dir,envir=e) reload(e) invisible(e) } reload <- function(e){ path = get("__path__",e) files = list.files(path,".R$",full.names=TRUE,recursive=TRUE,ignore.case=TRUE) for(f in files){ sys.source(f,envir=e) } } Now put the source code in some folder/directory somewhere. You can even make subdirs if you wish to organise it that way. I've got some .R files in "lib1". I do; > import("lib1") and that runs 'source' on all the .R files in there and loads them into position 2 on the search list. ls(pos=2) shows them. If you edit the source code, just do reload(2) (assuming it hasn't moved because you've loaded another package) and your stuff will be updated. It just sources everything again. Do detach(2) to get rid of it. If you want to distribute your code in "source" format, just make a zip or tar of the folder with the code in, and make sure your users have the import and reload functions (I should probably put them in a package one day...). To distribute in 'binary' format, do an import, and then save as .RData: > save(list=ls(pos=2),file="lib1.RData", envir=as.environment(2)) # not well tested.... Then your users just need to attach("lib1.RData") to get your functions. Now this scheme could get more complex - for example it doesn't deal with C or Fortran code, or documentation, or tests, or examples, or version numbering. Adding any of those would be pointless - if you want any of that either use packages and learn to write R docs (roxygen helps) or add it to my code yourself. You'll end up rebuilding the R package system anyway. Hope this helps. Doubtless someone else will come up with a simple way to build proper packages without all the bondage and discipline that annoys you. Barry
>>> "Dr. Michael Wolf" <m-wolf at muenster.de> 11/02/2011 07:52 >>> >is there an easier way to write R packages for the own use - withoutRTools and TeX? Installing Rtools is not hard, and doesn't have to happen often; the hardest bit in Windows is making sure that the requisite executables are on the path, and that just involves adding the directory names to the path environment variable. If I understand you, the problem is the time spent hacking about in the .Rd help files. That can certainly be simplified - eliminated, in fact. Use package.skeleton() once you have a good starting set of functions and data in R. That creates all the necessary directories, creates skeleton (but valid) .Rd files, and exports your functions and data objects for you. You can then edit the code directly, use RCMD check to check the package (useful anyway) and use RCMD build to build it. (In fact if all you want is the zip, you can - or at least could - zip the package directory created by RCMD check). S Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
On 2/11/2011 2:52 AM, Dr. Michael Wolf wrote:> Dear R colleagues, >...> From the point of the costs e. g. I had to learn writing help files in > a TeX-like language. But I'm the typical Word user. My last TeX writings > were done in the 1990s! If I'm changing only a letter in a source file > (r-file or help file) I've to build a new package. Seeing the results in > my eyes this is a very expansive way. It's easier to me to write those > files in HTML and to change the HTML source code. I don't need help > files in Rd format. >You can make things a whole lot easier by using prompt() to write the skeletons of the .Rd files. Then you have a ready-made template for your function or data and only need to fill in the details. Once you try this, you'll find it's not really any different than HTML markup. ?prompt