[R] Package Building under Windows with MikTeX 2.6
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Nov 25 17:22:48 CET 2007
Mark Hempelmann wrote:
> Dear WizaRds,
>
> I wrote a small function in R and would like to create a package. The
> necessary documentation is done, Rtools etc. are installed and I am
> still unable to complete the process under Windows. I did extensive
> research in the archives and read the Murdoch-Sutherland website on the
> Rtools and MikTeX hints. I realize that I understand only half or less
> of what is said there concerning the MikTeX-R interaction in creating
> packages. I am sorry.
>
> I also read the very helpful Rossi paper on 'Making R Packages under
> Windows. A Tutorial' as of 2006/01. I also tried to understand the .pdf
> on Writing R Extensions Version 2.5.1 (2007-09-04). Because of its
> condensed form it *might* present a true challenge to the uninitiated. I
> wish to apologize for not being able to comprehensively follow all of
> your "prescriptions", as pointed out in the manual: "This section
> contains a lot of prescriptive comments. They are here as a result of
> bitter experience. Please do not report problems to R-help unless you
> have followed all the prescriptions." Therefore, I hesitated long to
> report my problems, but since I spent long hours without any progress, I
> simply don't know anymore what to do. Is there anyone willing to help?
>
> I installed MikTex, Perl, htmlhelp, Rtools and WinEdt for editing
> purposes, and changed the path in the system environment as follows
> (Carriage return for readability):
> System Path:
> C:\Programme\Uni\Rtools\bin;
> C:\Programme\Uni\Perl\bin;
> C:\Programme\Uni\Rtools\MinGW\bin;
> C:\Programme\Uni\hmtlhelp;
> C:\Programme\Uni\R\bin;
> C:\Programme\Uni\MikTeX\miktex\bin;
> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
>
> User Path (?what is this for?)
> C:\Programme\Uni\MikTeX\miktex\bin
>
>
The user path is prepended to the system path, so you've got miktex
first. I'd delete it, because you really want Rtools first.
> R Version: R version 2.5.1 Patched (2007-09-04 r42845)
> Rtools Version: 2.6.0.1216
>
The tools you have were written to work with R 2.6.0. I think they'll
work with 2.5.1, but I'd recommend upgrading R to 2.6.1 (when it is
released tomorrow). Building packages is getting easier.
> MikTeX 2.6
>
> Directory Structure MikTeX, R, Rtools, WinEdt etc. (hierarchy with tabs):
> C:\Uni\MikTeX
> C:\Uni\R\
> bin
> doc
> etc
> include
> library
> modules
> share\
> licenses
> locale
> make
> perl\
> R
> Text
> R
> texmf
> src
> Tcl
>
> C:\Uni\Rtools
> C:\Uni\WinEdt
> C:\Uni\Perl
> C:\Uni\htmlhelp
>
> I generated the minimal package structure for package mbes via
> skeleton(), consisting of
> c:\RWork\mbes\
> man\mbes.Rd
> man\mbes.package.Rd
> R\mbes.R
> DESCRIPTION
>
> and then in a MS DOS command window:
> R CMD check mbes
>
> which called forth the error:
> Error message:
> C:\RWork\mbes>R CMD check mbes
> * checking for working latex ...Error: environment variable TMPDIR not
> set (or set to unusable value) and no default available.
> at C:\Programme\Uni\R\share\perl/R/Utils.pm line 73
>
You should set up TMPDIR (or TEMP, or TMP) to point to a writable directory.
Duncan Murdoch
> I looked at the path and Utils.pm shows:
> ...
> ### * R_tempfile
> sub R_tempfile {
> my $pat = "Rutils";
> $pat = $_[0] if $_[0];
> R::Vars::error("TMPDIR");
> my $retval = file_path($R::Vars::TMPDIR,
> $pat . $$ . sprintf("%05d", rand(10**5)));
>
> my $n=0;
> while(-e $retval) { # was -f, but want to be able to create such a file
> $retval = file_path($R::Vars::TMPDIR,
> $pat . $$ . sprintf("%05d", rand(10**5)));
> croak "Cannot find unused name for temporary file"
> if($n++ > 1000);
> }
> $retval;
> }
> ### * R_system
> sub R_system
> {
> my ($cmd, $Renv) = @_;
> my $tmpf = R_tempfile();
> if($R::Vars::OSTYPE eq "windows") {
> open(tmpf, "> $tmpf")
> or die "Error: cannot write to '$tmpf'\n";
> print tmpf "$cmd $Renv\n";
> close tmpf;
> $res = system("sh $tmpf");
> unlink($tmpf);
> return $res;
> } else {
> return system("$Renv $cmd");
> }
> }
> ...
>
> I simply don't know what to do. I am very grateful for any help.
> Thank you so much.
> Yours
> Mark
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list