[R] writing R extension

Hans-Peter gchappi at gmail.com
Wed Dec 20 18:42:47 CET 2006


2006/12/20, michele de meo <vbarstat at gmail.com>:
> I'd like to develop a simple library in R in which to save my
> particular functions.

> I know that it's possible to save functions in the workspace, but I
> need this functions in a library.

- As an option you could also save the function in a textfile and
source it in the beginning of an R session (-> e.g. in the
profile.site file in RHOME\etc

- Otherwise you will have to re-read about building packages. Packages
are great (e.g. for consistent documentation, tests, ...) but have the
disadvantage that they are more complicated and less flexible than
just sourcing code. If your code changes (often) I'd recommend to
automate the whole package-building-process.

If you are on windows, maybe the following which I had laying around will help:

<<
Download and Install
--------------------
- Perl: http://activestate.com/store/activeperl/
- Rtools: http://www.murdoch-sutherland.com/Rtools/tools.zip
  (extract in a directory like e.g. programme\R\Rtools)
- MS HTML Help Workshop:
http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwmicrosofthtmlhelpdownloads.asp
- TeX: 	download current version at: http://www.miktex.org/
	at the moment:
http://prdownloads.sourceforge.net/miktex/basic-miktex-2.5.2471.exe?download

Adjust Windows environmental variables (~System->Erweitert->Umgebungsvariablen)
--------------------
- PATH: In this variable the paths to the installed programs above
have to be. With the installation this has normally be done
automatically. For the Rtools you have to do it yourself: add the path
to the tools bin folder. Take care not to change the other paths. And
check if the path for the programs above are correct/included. A GOOD
IDEA is to copy the whole path in a text editor, modify and copy it
back.
- If I remember correctly the TeX program needs a nonstandard temp
directory variable: "TMPDIR". Add this variable to the system
variables, choose the same value as for the other temp variable (TEMP,
TMP, ...).

Optional tools
-------------
- yap (to read *.dvi files, maybe this is already included in the
miktex TeX download)

Additonal info
-------------
[1] http://statmath.wu-wien.ac.at/staff/dekic/Rwin/
[2] http://statmath.wu-wien.ac.at/staff/dekic/Rwin/LinkedDocuments/Anleitung.pdf
[3] http://www.murdoch-sutherland.com/Rtools/
>>

Use package.skeleton to make a prototype (this is VERY useful). To
build the packages you can use bat (batch) files, e.g. something like:
set rver=2.3.1
set rcmd="C:\Programme\R\R-%rver%\bin\Rcmd.exe"
%rcmd% check %prj%
%rcmd% INSTALL --docs="txt,html,example,chm" --library=../../TempInstall %prj%

-- 
Regards,
Hans-Peter



More information about the R-help mailing list