package building problem under Windows Vista

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

package building problem under Windows Vista

Fox, John
Dear list members,

I've encountered the following problem trying to build a package under
Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0 RC
(from which this output was produced). The package builds just fine on my XP
(SP2) machine. Please see some further comments below.

---------- snip -------------

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

d:\R-packages>R CMD build tradeCosts
* checking for file 'tradeCosts/DESCRIPTION' ... OK
* preparing 'tradeCosts':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
installing R.css in C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586


---------- Making package tradeCosts ------------
  adding build stamp to DESCRIPTION
  installing NAMESPACE file and metadata
Error in file(file, "r") : unable to open connection
Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
In addition: Warning message:
In file(file, "r") :
  cannot open file
'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
ts/NAMESPACE', reason 'Permission denied'
Execution halted
make[2]: *** [nmspace] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-tradeCosts] Error 2
*** Installation of tradeCosts failed ***

Removing 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
* creating vignettes ... OK
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'tradeCosts_0.3-0.tar.gz'


d:\R-packages>

---------- snip -------------

I believe that the error is related to the vignette in the package, since I
can build packages without a vignette. Clearly there is a file-permission
problem but: (1) I'm using an account with administrator privileges; (2) R
is installed into c:\R (and the problem persists even when I install R into
d:\R); (3) the problem persists when I run the command window and R itself
as administrator, and when I turn off account controls; (4) the problems
persists when I reset the environment variables temp and tmp to d:\temp and
set the permissions to d:\temp so that all groups and users have full
control over that directory.

I'm tempted to dump Vista but I've been trying to persist with it since most
people (e.g., my students) buying new Windows machines will be getting it.
Although I've read section 2.24 of the R for Windows FAQ, it's quite
possible that I've missed something of relevance there.

Any help would be appreciated.

Thanks in advance,
 John

--------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Prof Brian Ripley
John,

The environment variables are case-sensitive (not temp and tmp), and
TMPDIR is the one used by 'R CMD build'. I think you need to set TMPDIR to
somewhere known to have full control.  Why that is not true of
C:/Users/JOHNFO~1/AppData/Local/Temp is unclear to me, but I don't think
anything you said you did would have tried a different location.

Brian

On Sat, 19 Apr 2008, John Fox wrote:

> Dear list members,
>
> I've encountered the following problem trying to build a package under
> Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0 RC
> (from which this output was produced). The package builds just fine on my XP
> (SP2) machine. Please see some further comments below.
>
> ---------- snip -------------
>
> Microsoft Windows [Version 6.0.6001]
> Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
>
> d:\R-packages>R CMD build tradeCosts
> * checking for file 'tradeCosts/DESCRIPTION' ... OK
> * preparing 'tradeCosts':
> * checking DESCRIPTION meta-information ... OK
> * installing the package to re-build vignettes
> installing R.css in C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
>
>
> ---------- Making package tradeCosts ------------
>  adding build stamp to DESCRIPTION
>  installing NAMESPACE file and metadata
> Error in file(file, "r") : unable to open connection
> Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
> In addition: Warning message:
> In file(file, "r") :
>  cannot open file
> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
> ts/NAMESPACE', reason 'Permission denied'
> Execution halted
> make[2]: *** [nmspace] Error 1
> make[1]: *** [all] Error 2
> make: *** [pkg-tradeCosts] Error 2
> *** Installation of tradeCosts failed ***
>
> Removing 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
> * creating vignettes ... OK
> * removing junk files
> * checking for LF line-endings in source and make files
> * checking for empty or unneeded directories
> * building 'tradeCosts_0.3-0.tar.gz'
>
>
> d:\R-packages>
>
> ---------- snip -------------
>
> I believe that the error is related to the vignette in the package, since I
> can build packages without a vignette. Clearly there is a file-permission
> problem but: (1) I'm using an account with administrator privileges; (2) R
> is installed into c:\R (and the problem persists even when I install R into
> d:\R); (3) the problem persists when I run the command window and R itself
> as administrator, and when I turn off account controls; (4) the problems
> persists when I reset the environment variables temp and tmp to d:\temp and
> set the permissions to d:\temp so that all groups and users have full
> control over that directory.
>
> I'm tempted to dump Vista but I've been trying to persist with it since most
> people (e.g., my students) buying new Windows machines will be getting it.
> Although I've read section 2.24 of the R for Windows FAQ, it's quite
> possible that I've missed something of relevance there.
>
> Any help would be appreciated.
>
> Thanks in advance,
> John
>
> --------------------------------
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Gabor Grothendieck
In reply to this post by Fox, John
Note that CRAN is also having a problem with the package
so its not just you:

http://cran.r-project.org/bin/windows/contrib/2.7/check/tm-check.log

I also have a problem with the vignettes (note
there are two) but as with you this works:

Rcmd build --no-vignettes tradeCosts

I don't have any special environment variables set for temporary
directories and I use C:\Program Files\R\...
for R.  I use Rcmd.bat and sweave.bat from batchfiles found at:
http://batchfiles.googlecode.com
which finds R in the registry so no paths need be set.
I am on Vista but you seem to have SP1 which I don't
have yet.

I can build other packages so there
is probably something that needs fixing in their vignettes.

On Sat, Apr 19, 2008 at 7:52 AM, John Fox <[hidden email]> wrote:

> Dear list members,
>
> I've encountered the following problem trying to build a package under
> Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0 RC
> (from which this output was produced). The package builds just fine on my XP
> (SP2) machine. Please see some further comments below.
>
> ---------- snip -------------
>
> Microsoft Windows [Version 6.0.6001]
> Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
>
> d:\R-packages>R CMD build tradeCosts
> * checking for file 'tradeCosts/DESCRIPTION' ... OK
> * preparing 'tradeCosts':
> * checking DESCRIPTION meta-information ... OK
> * installing the package to re-build vignettes
> installing R.css in C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
>
>
> ---------- Making package tradeCosts ------------
>  adding build stamp to DESCRIPTION
>  installing NAMESPACE file and metadata
> Error in file(file, "r") : unable to open connection
> Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
> In addition: Warning message:
> In file(file, "r") :
>  cannot open file
> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
> ts/NAMESPACE', reason 'Permission denied'
> Execution halted
> make[2]: *** [nmspace] Error 1
> make[1]: *** [all] Error 2
> make: *** [pkg-tradeCosts] Error 2
> *** Installation of tradeCosts failed ***
>
> Removing 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
> * creating vignettes ... OK
> * removing junk files
> * checking for LF line-endings in source and make files
> * checking for empty or unneeded directories
> * building 'tradeCosts_0.3-0.tar.gz'
>
>
> d:\R-packages>
>
> ---------- snip -------------
>
> I believe that the error is related to the vignette in the package, since I
> can build packages without a vignette. Clearly there is a file-permission
> problem but: (1) I'm using an account with administrator privileges; (2) R
> is installed into c:\R (and the problem persists even when I install R into
> d:\R); (3) the problem persists when I run the command window and R itself
> as administrator, and when I turn off account controls; (4) the problems
> persists when I reset the environment variables temp and tmp to d:\temp and
> set the permissions to d:\temp so that all groups and users have full
> control over that directory.
>
> I'm tempted to dump Vista but I've been trying to persist with it since most
> people (e.g., my students) buying new Windows machines will be getting it.
> Although I've read section 2.24 of the R for Windows FAQ, it's quite
> possible that I've missed something of relevance there.
>
> Any help would be appreciated.
>
> Thanks in advance,
>  John
>
> --------------------------------
> John Fox, Professor
> Department of Sociology
> McMaster University
> Hamilton, Ontario, Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Fox, John
In reply to this post by Prof Brian Ripley
Dear Brian,

Actually, though it's irrelevant, I did set the environment variables TEMP
and TMP (and of course forgot that R uses TMPDIR instead).

Unfortunately, setting TMPDIR to d:\temp doesn't solve the problem:

------------ snip -------------

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

d:\R-packages>set TMPDIR
TMPDIR=d:\temp

d:\R-packages>R CMD build tradeCosts
* checking for file 'tradeCosts/DESCRIPTION' ... OK
* preparing 'tradeCosts':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
installing R.css in d:/temp/Rinst542048336


---------- Making package tradeCosts ------------
  adding build stamp to DESCRIPTION
  installing NAMESPACE file and metadata
Error in file(file, "r") : unable to open connection
Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
In addition: Warning message:
In file(file, "r") :
  cannot open file 'd:/temp/Rinst542048336/tradeCosts/NAMESPACE', reason
'Permis
sion denied'
Execution halted
make[2]: *** [nmspace] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-tradeCosts] Error 2
*** Installation of tradeCosts failed ***

Removing 'd:/temp/Rinst542048336/tradeCosts'
* creating vignettes ... OK
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'tradeCosts_0.3-0.tar.gz'


d:\R-packages>

------------ snip -------------

Thank you for the suggestion,
 John


> -----Original Message-----
> From: Prof Brian Ripley [mailto:[hidden email]]
> Sent: April-19-08 8:53 AM
> To: John Fox
> Cc: 'R-devel'
> Subject: Re: [Rd] package building problem under Windows Vista
>
> John,
>
> The environment variables are case-sensitive (not temp and tmp), and
> TMPDIR is the one used by 'R CMD build'. I think you need to set TMPDIR
> to
> somewhere known to have full control.  Why that is not true of
> C:/Users/JOHNFO~1/AppData/Local/Temp is unclear to me, but I don't
> think
> anything you said you did would have tried a different location.
>
> Brian
>
> On Sat, 19 Apr 2008, John Fox wrote:
>
> > Dear list members,
> >
> > I've encountered the following problem trying to build a package
> under
> > Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0
> RC
> > (from which this output was produced). The package builds just fine
> on my XP
> > (SP2) machine. Please see some further comments below.
> >
> > ---------- snip -------------
> >
> > Microsoft Windows [Version 6.0.6001]
> > Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
> >
> > d:\R-packages>R CMD build tradeCosts
> > * checking for file 'tradeCosts/DESCRIPTION' ... OK
> > * preparing 'tradeCosts':
> > * checking DESCRIPTION meta-information ... OK
> > * installing the package to re-build vignettes
> > installing R.css in
> C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
> >
> >
> > ---------- Making package tradeCosts ------------
> >  adding build stamp to DESCRIPTION
> >  installing NAMESPACE file and metadata
> > Error in file(file, "r") : unable to open connection
> > Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
> > In addition: Warning message:
> > In file(file, "r") :
> >  cannot open file
> > 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
> > ts/NAMESPACE', reason 'Permission denied'
> > Execution halted
> > make[2]: *** [nmspace] Error 1
> > make[1]: *** [all] Error 2
> > make: *** [pkg-tradeCosts] Error 2
> > *** Installation of tradeCosts failed ***
> >
> > Removing
> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
> > * creating vignettes ... OK
> > * removing junk files
> > * checking for LF line-endings in source and make files
> > * checking for empty or unneeded directories
> > * building 'tradeCosts_0.3-0.tar.gz'
> >
> >
> > d:\R-packages>
> >
> > ---------- snip -------------
> >
> > I believe that the error is related to the vignette in the package,
> since I
> > can build packages without a vignette. Clearly there is a file-
> permission
> > problem but: (1) I'm using an account with administrator privileges;
> (2) R
> > is installed into c:\R (and the problem persists even when I install
> R into
> > d:\R); (3) the problem persists when I run the command window and R
> itself
> > as administrator, and when I turn off account controls; (4) the
> problems
> > persists when I reset the environment variables temp and tmp to
> d:\temp and
> > set the permissions to d:\temp so that all groups and users have full
> > control over that directory.
> >
> > I'm tempted to dump Vista but I've been trying to persist with it
> since most
> > people (e.g., my students) buying new Windows machines will be
> getting it.
> > Although I've read section 2.24 of the R for Windows FAQ, it's quite
> > possible that I've missed something of relevance there.
> >
> > Any help would be appreciated.
> >
> > Thanks in advance,
> > John
> >
> > --------------------------------
> > John Fox, Professor
> > Department of Sociology
> > McMaster University
> > Hamilton, Ontario, Canada L8S 4M4
> > 905-525-9140x23604
> > http://socserv.mcmaster.ca/jfox
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
> --
> Brian D. Ripley,                  [hidden email]
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Fox, John
In reply to this post by Gabor Grothendieck
Dear Gabor,

> -----Original Message-----
> From: Gabor Grothendieck [mailto:[hidden email]]
> Sent: April-19-08 9:10 AM
> To: John Fox
> Cc: R-devel
> Subject: Re: [Rd] package building problem under Windows Vista
>
> Note that CRAN is also having a problem with the package
> so its not just you:
>
> http://cran.r-project.org/bin/windows/contrib/2.7/check/tm-check.log

I'm afraid that I don't see a problem in that check log -- just a string of
OKs -- though there is a warning in the log at
http://cran.r-project.org/bin/windows/contrib/2.7/check/tradeCosts-check.log
. Recall, however, that the package builds (and checks) just fine for me
under XP SP2, and that the package fails to build under R 2.6.2 on Vista,
for which there is no warning in the package check.

When you try to build the tradeCosts package *with* the vignettes, do you
get the same file-permission error that I do? Have you been able to build
other packages with both vignettes and namespaces successfully?

Thanks for the suggestions.

John

>
> I also have a problem with the vignettes (note
> there are two) but as with you this works:
>
> Rcmd build --no-vignettes tradeCosts
>
> I don't have any special environment variables set for temporary
> directories and I use C:\Program Files\R\...
> for R.  I use Rcmd.bat and sweave.bat from batchfiles found at:
> http://batchfiles.googlecode.com
> which finds R in the registry so no paths need be set.
> I am on Vista but you seem to have SP1 which I don't
> have yet.
>
> I can build other packages so there
> is probably something that needs fixing in their vignettes.
>
> On Sat, Apr 19, 2008 at 7:52 AM, John Fox <[hidden email]> wrote:
> > Dear list members,
> >
> > I've encountered the following problem trying to build a package
> under
> > Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0
> RC
> > (from which this output was produced). The package builds just fine
> on my XP
> > (SP2) machine. Please see some further comments below.
> >
> > ---------- snip -------------
> >
> > Microsoft Windows [Version 6.0.6001]
> > Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
> >
> > d:\R-packages>R CMD build tradeCosts
> > * checking for file 'tradeCosts/DESCRIPTION' ... OK
> > * preparing 'tradeCosts':
> > * checking DESCRIPTION meta-information ... OK
> > * installing the package to re-build vignettes
> > installing R.css in
> C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
> >
> >
> > ---------- Making package tradeCosts ------------
> >  adding build stamp to DESCRIPTION
> >  installing NAMESPACE file and metadata
> > Error in file(file, "r") : unable to open connection
> > Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
> > In addition: Warning message:
> > In file(file, "r") :
> >  cannot open file
> > 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
> > ts/NAMESPACE', reason 'Permission denied'
> > Execution halted
> > make[2]: *** [nmspace] Error 1
> > make[1]: *** [all] Error 2
> > make: *** [pkg-tradeCosts] Error 2
> > *** Installation of tradeCosts failed ***
> >
> > Removing
> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
> > * creating vignettes ... OK
> > * removing junk files
> > * checking for LF line-endings in source and make files
> > * checking for empty or unneeded directories
> > * building 'tradeCosts_0.3-0.tar.gz'
> >
> >
> > d:\R-packages>
> >
> > ---------- snip -------------
> >
> > I believe that the error is related to the vignette in the package,
> since I
> > can build packages without a vignette. Clearly there is a file-
> permission
> > problem but: (1) I'm using an account with administrator privileges;
> (2) R
> > is installed into c:\R (and the problem persists even when I install
> R into
> > d:\R); (3) the problem persists when I run the command window and R
> itself
> > as administrator, and when I turn off account controls; (4) the
> problems
> > persists when I reset the environment variables temp and tmp to
> d:\temp and
> > set the permissions to d:\temp so that all groups and users have full
> > control over that directory.
> >
> > I'm tempted to dump Vista but I've been trying to persist with it
> since most
> > people (e.g., my students) buying new Windows machines will be
> getting it.
> > Although I've read section 2.24 of the R for Windows FAQ, it's quite
> > possible that I've missed something of relevance there.
> >
> > Any help would be appreciated.
> >
> > Thanks in advance,
> >  John
> >
> > --------------------------------
> > John Fox, Professor
> > Department of Sociology
> > McMaster University
> > Hamilton, Ontario, Canada L8S 4M4
> > 905-525-9140x23604
> > http://socserv.mcmaster.ca/jfox
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Gabor Grothendieck
There does seem to be some general problem associated with Sweave
and graphics when I try it on my Vista system with
[1] "R version 2.7.0 RC (2008-04-17 r45367)"

Using tradeCosts-article.Rnw from the tradeCosts package:

    setwd(path.to.tradeCosts-article.Rnw)
    Sweave("tradeCosts-article.Rnw")

appears to work properly; however, if we try it from the
command line:

    R CMD Sweave tradeCosts-article.Rnw

to simulate what happens when trying to build the package it
indicates that in chunk 2 that pdf is masked from grDevices.
Then in chunk 17, when plotting is attempted the first time,
it chokes.

Maybe someone familiar with the relevant internals can explain.

I have shown chunks 1, 2 and 17 as output from Stangle,
the Rnw file up to the end of chunk 2 and the error log
from Sweave in the sections below.


-------------------------------------------------------------------------
###################################################
### chunk number 1:
###################################################
options(digits = 3, width = 60, scipen = 99)
set.seed(1)

cat.df.without.rownames <- function (d, file = ""){
  stopifnot(is.data.frame(d))
  row.names(d) <- 1:nrow(d)
  x <- NULL
  conn <- textConnection("x", "w", local = TRUE)
  capture.output(print(d), file = conn)
  close(conn)
  cat(substring(x, first = max(nchar(row.names(d))) + 2), sep = "\n",
      file = file)
}


###################################################
### chunk number 2:
###################################################
library(tradeCosts)
data(trade.mar.2007)
head(trade.mar.2007)


###################################################
### chunk number 17:
###################################################
plot(result.batched, "time.series.bps")

-------------------------------------------------------------------------


\documentclass[a4paper]{report}
\usepackage[round]{natbib}

\usepackage{Rnews}
\usepackage{fancyvrb}
\usepackage{Sweave}
\hyphenation{tradeCosts}
\hyphenation{tradeCostsResults}
\hyphenation{decision}

\DefineVerbatimEnvironment{Sinput}{Verbatim}{fontsize=\small,fontshape=sl}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontsize=\small,fontshape=sl}

%% \SweaveOpts{prefix.string=graphics/portfolio}

\bibliographystyle{abbrvnat}

\begin{document}
\begin{article}
\title{Trade Costs}
\author{Jeff Enos, David Kane, Arjun Ravi Narayan, Aaron Schwartz,
Daniel Suo and Luyi Zhao}

%%\VignetteIndexEntry{Trade Costs}
%%\VignetteDepends{tradeCosts}

<<echo = FALSE>>=
options(digits = 3, width = 60, scipen = 99)
set.seed(1)

cat.df.without.rownames <- function (d, file = ""){
  stopifnot(is.data.frame(d))
  row.names(d) <- 1:nrow(d)
  x <- NULL
  conn <- textConnection("x", "w", local = TRUE)
  capture.output(print(d), file = conn)
  close(conn)
  cat(substring(x, first = max(nchar(row.names(d))) + 2), sep = "\n",
      file = file)
}
@

\maketitle

\setkeys{Gin}{width=0.95\textwidth}


\section*{Introduction}

Trade costs are the costs a trader must pay to implement a decision to
buy or sell a security. Consider a single trade of a single equity
security. Suppose on the evening of August 1, a trader decides to
purchase 10,000 shares of IBM at \$10, the \emph{decision price} of
the trade.  The next day, the trader's broker buys 10,000 shares in a
rising market and pays \$11 per share, the trade's \emph{execution price}.

How much did it cost to implement this trade?  In the most basic
ex-post analysis, trade costs are calculated by comparing the
execution price of a trade to a benchmark price.\footnote{For an
  in-depth discussion of both ex-ante modeling and ex-post measurement
  of trade costs, see \citet{kissell:glantz}.}  Suppose we
wished to compare the execution price to the price of the security at
the time of the decision in the above example.  Since the trader's
decision occurred at \$10 and the broker paid \$11, the cost of the
trade relative to the decision price was $\$11 - \$10 = \$1$ per
share, or \$10,000 (9.1\% of the total value of the execution).

Measuring costs relative to a trade's decision price captures costs
associated with the delay in the release of a trade into the market
and movements in price after the decision was made but before the
order is completed.  It does not, however, provide a means to
determine whether the broker's execution reflects a fair price. For
example, the price of \$11 would be a poor price if most transactions
in IBM on August 2 occurred at \$10.50.  For this purpose a better
benchmark would be the day's volume-weighted average price, or VWAP.
If VWAP on August 2 was \$10.50 and the trader used this as her
benchmark, then the trade cost would be \$0.50 per share, or \$500.

The first version of the \pkg{tradeCosts} package provides a simple
framework for calculating the cost of trades relative to a benchmark
price, such as VWAP or decision price, over multiple periods and basic
reporting and plotting facilities to analyse these costs.

\section*{Trade costs in a single period}
Suppose we want to calculate trade costs for a single period.  First,
the data required to run the analysis must be assembled into three
data frames.  A sample of each of the three types of data has been included
with the package in three data sets.

The first data frame contains all trade-specific information, a sample
of which is in the \texttt{trade.mar.2007} data frame:

<<echo=TRUE>>=
library(tradeCosts)
data(trade.mar.2007)
head(trade.mar.2007)
@

-------------------------------------------------------------------------

Here is the result of sweaving:

Writing to file tradeCosts-article.tex
Processing code chunks ...
 1 : term verbatim
 2 : echo term verbatim
Loading required package: tools

Attaching package: 'tradeCosts'


        The following object(s) are masked from package:grDevices :

         pdf

 3 : echo term verbatim
 4 : echo term verbatim
 5 : term verbatim
 6 : echo term verbatim
 7 : term verbatim
 8 : echo term verbatim
 9 : echo term verbatim
10 : term verbatim
11 : echo term verbatim
12 : term verbatim
13 : echo term verbatim
14 : term verbatim
15 : term verbatim
16 : term verbatim
17 : echo term verbatim eps pdf

Error:  chunk 17
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "pdf", for signature "missing"

Execution halted





> Thanks for the suggestions.
>
> John
>
>
> >
> > I also have a problem with the vignettes (note
> > there are two) but as with you this works:
> >
> > Rcmd build --no-vignettes tradeCosts
> >
> > I don't have any special environment variables set for temporary
> > directories and I use C:\Program Files\R\...
> > for R.  I use Rcmd.bat and sweave.bat from batchfiles found at:
> > http://batchfiles.googlecode.com
> > which finds R in the registry so no paths need be set.
> > I am on Vista but you seem to have SP1 which I don't
> > have yet.
> >
> > I can build other packages so there
> > is probably something that needs fixing in their vignettes.
> >
> > On Sat, Apr 19, 2008 at 7:52 AM, John Fox <[hidden email]> wrote:
> > > Dear list members,
> > >
> > > I've encountered the following problem trying to build a package
> > under
> > > Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0
> > RC
> > > (from which this output was produced). The package builds just fine
> > on my XP
> > > (SP2) machine. Please see some further comments below.
> > >
> > > ---------- snip -------------
> > >
> > > Microsoft Windows [Version 6.0.6001]
> > > Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
> > >
> > > d:\R-packages>R CMD build tradeCosts
> > > * checking for file 'tradeCosts/DESCRIPTION' ... OK
> > > * preparing 'tradeCosts':
> > > * checking DESCRIPTION meta-information ... OK
> > > * installing the package to re-build vignettes
> > > installing R.css in
> > C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
> > >
> > >
> > > ---------- Making package tradeCosts ------------
> > >  adding build stamp to DESCRIPTION
> > >  installing NAMESPACE file and metadata
> > > Error in file(file, "r") : unable to open connection
> > > Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
> > > In addition: Warning message:
> > > In file(file, "r") :
> > >  cannot open file
> > > 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
> > > ts/NAMESPACE', reason 'Permission denied'
> > > Execution halted
> > > make[2]: *** [nmspace] Error 1
> > > make[1]: *** [all] Error 2
> > > make: *** [pkg-tradeCosts] Error 2
> > > *** Installation of tradeCosts failed ***
> > >
> > > Removing
> > 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
> > > * creating vignettes ... OK
> > > * removing junk files
> > > * checking for LF line-endings in source and make files
> > > * checking for empty or unneeded directories
> > > * building 'tradeCosts_0.3-0.tar.gz'
> > >
> > >
> > > d:\R-packages>
> > >
> > > ---------- snip -------------
> > >
> > > I believe that the error is related to the vignette in the package,
> > since I
> > > can build packages without a vignette. Clearly there is a file-
> > permission
> > > problem but: (1) I'm using an account with administrator privileges;
> > (2) R
> > > is installed into c:\R (and the problem persists even when I install
> > R into
> > > d:\R); (3) the problem persists when I run the command window and R
> > itself
> > > as administrator, and when I turn off account controls; (4) the
> > problems
> > > persists when I reset the environment variables temp and tmp to
> > d:\temp and
> > > set the permissions to d:\temp so that all groups and users have full
> > > control over that directory.
> > >
> > > I'm tempted to dump Vista but I've been trying to persist with it
> > since most
> > > people (e.g., my students) buying new Windows machines will be
> > getting it.
> > > Although I've read section 2.24 of the R for Windows FAQ, it's quite
> > > possible that I've missed something of relevance there.
> > >
> > > Any help would be appreciated.
> > >
> > > Thanks in advance,
> > >  John
> > >
> > > --------------------------------
> > > John Fox, Professor
> > > Department of Sociology
> > > McMaster University
> > > Hamilton, Ontario, Canada L8S 4M4
> > > 905-525-9140x23604
> > > http://socserv.mcmaster.ca/jfox
> > >
> > > ______________________________________________
> > > [hidden email] mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-devel
> > >
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Duncan Murdoch
On 20/04/2008 8:43 AM, Gabor Grothendieck wrote:

> There does seem to be some general problem associated with Sweave
> and graphics when I try it on my Vista system with
> [1] "R version 2.7.0 RC (2008-04-17 r45367)"
>
> Using tradeCosts-article.Rnw from the tradeCosts package:
>
>     setwd(path.to.tradeCosts-article.Rnw)
>     Sweave("tradeCosts-article.Rnw")
>
> appears to work properly; however, if we try it from the
> command line:
>
>     R CMD Sweave tradeCosts-article.Rnw
>
> to simulate what happens when trying to build the package it
> indicates that in chunk 2 that pdf is masked from grDevices.

tradeCosts has its own pdf(), which is an S4 generic.  Once you have
attached that package, the regular pdf() device driver is hidden.  So it
looks as though running Sweave from the R console does the search in the
intended way, but running it from R CMD Sweave finds the tradeCosts
version of pdf() instead of the standard one.  I don't see why there's
any difference here, but utils (where Sweave lives) doesn't state that
it depends on grDevices (which is where the standard pdf() comes from).
However, fixing this is not enough to fix the error.

I see that tradeCosts doesn't declare any dependency on grDevices;
fixing that also doesn't fix the problem.

When tradeCosts creates the S4 generic for pdf(), it uses a signature
that is inconsistent with the standard one; that might be the problem.
However, I don't see how to fix it.  The docs for setGeneric suggest
simply using

  setGeneric("pdf")

but that doesn't work:

Loading required package: grDevices
Loading required package: graphics
Loading required package: stats
Loading required package: tools
Error in setGeneric("pdf") :
   must supply a function skeleton, explicitly or via an existing function

I don't know why setGeneric can't see pdf() in grDevices.  I think John
Chambers is offline for a while, so this will likely have to wait.

Duncan Murdoch



> Then in chunk 17, when plotting is attempted the first time,
> it chokes.
>
> Maybe someone familiar with the relevant internals can explain.
>
> I have shown chunks 1, 2 and 17 as output from Stangle,
> the Rnw file up to the end of chunk 2 and the error log
> from Sweave in the sections below.
>
>
> -------------------------------------------------------------------------
> ###################################################
> ### chunk number 1:
> ###################################################
> options(digits = 3, width = 60, scipen = 99)
> set.seed(1)
>
> cat.df.without.rownames <- function (d, file = ""){
>   stopifnot(is.data.frame(d))
>   row.names(d) <- 1:nrow(d)
>   x <- NULL
>   conn <- textConnection("x", "w", local = TRUE)
>   capture.output(print(d), file = conn)
>   close(conn)
>   cat(substring(x, first = max(nchar(row.names(d))) + 2), sep = "\n",
>       file = file)
> }
>
>
> ###################################################
> ### chunk number 2:
> ###################################################
> library(tradeCosts)
> data(trade.mar.2007)
> head(trade.mar.2007)
>
>
> ###################################################
> ### chunk number 17:
> ###################################################
> plot(result.batched, "time.series.bps")
>
> -------------------------------------------------------------------------
>
>
> \documentclass[a4paper]{report}
> \usepackage[round]{natbib}
>
> \usepackage{Rnews}
> \usepackage{fancyvrb}
> \usepackage{Sweave}
> \hyphenation{tradeCosts}
> \hyphenation{tradeCostsResults}
> \hyphenation{decision}
>
> \DefineVerbatimEnvironment{Sinput}{Verbatim}{fontsize=\small,fontshape=sl}
> \DefineVerbatimEnvironment{Soutput}{Verbatim}{fontsize=\small}
> \DefineVerbatimEnvironment{Scode}{Verbatim}{fontsize=\small,fontshape=sl}
>
> %% \SweaveOpts{prefix.string=graphics/portfolio}
>
> \bibliographystyle{abbrvnat}
>
> \begin{document}
> \begin{article}
> \title{Trade Costs}
> \author{Jeff Enos, David Kane, Arjun Ravi Narayan, Aaron Schwartz,
> Daniel Suo and Luyi Zhao}
>
> %%\VignetteIndexEntry{Trade Costs}
> %%\VignetteDepends{tradeCosts}
>
> <<echo = FALSE>>=
> options(digits = 3, width = 60, scipen = 99)
> set.seed(1)
>
> cat.df.without.rownames <- function (d, file = ""){
>   stopifnot(is.data.frame(d))
>   row.names(d) <- 1:nrow(d)
>   x <- NULL
>   conn <- textConnection("x", "w", local = TRUE)
>   capture.output(print(d), file = conn)
>   close(conn)
>   cat(substring(x, first = max(nchar(row.names(d))) + 2), sep = "\n",
>       file = file)
> }
> @
>
> \maketitle
>
> \setkeys{Gin}{width=0.95\textwidth}
>
>
> \section*{Introduction}
>
> Trade costs are the costs a trader must pay to implement a decision to
> buy or sell a security. Consider a single trade of a single equity
> security. Suppose on the evening of August 1, a trader decides to
> purchase 10,000 shares of IBM at \$10, the \emph{decision price} of
> the trade.  The next day, the trader's broker buys 10,000 shares in a
> rising market and pays \$11 per share, the trade's \emph{execution price}.
>
> How much did it cost to implement this trade?  In the most basic
> ex-post analysis, trade costs are calculated by comparing the
> execution price of a trade to a benchmark price.\footnote{For an
>   in-depth discussion of both ex-ante modeling and ex-post measurement
>   of trade costs, see \citet{kissell:glantz}.}  Suppose we
> wished to compare the execution price to the price of the security at
> the time of the decision in the above example.  Since the trader's
> decision occurred at \$10 and the broker paid \$11, the cost of the
> trade relative to the decision price was $\$11 - \$10 = \$1$ per
> share, or \$10,000 (9.1\% of the total value of the execution).
>
> Measuring costs relative to a trade's decision price captures costs
> associated with the delay in the release of a trade into the market
> and movements in price after the decision was made but before the
> order is completed.  It does not, however, provide a means to
> determine whether the broker's execution reflects a fair price. For
> example, the price of \$11 would be a poor price if most transactions
> in IBM on August 2 occurred at \$10.50.  For this purpose a better
> benchmark would be the day's volume-weighted average price, or VWAP.
> If VWAP on August 2 was \$10.50 and the trader used this as her
> benchmark, then the trade cost would be \$0.50 per share, or \$500.
>
> The first version of the \pkg{tradeCosts} package provides a simple
> framework for calculating the cost of trades relative to a benchmark
> price, such as VWAP or decision price, over multiple periods and basic
> reporting and plotting facilities to analyse these costs.
>
> \section*{Trade costs in a single period}
> Suppose we want to calculate trade costs for a single period.  First,
> the data required to run the analysis must be assembled into three
> data frames.  A sample of each of the three types of data has been included
> with the package in three data sets.
>
> The first data frame contains all trade-specific information, a sample
> of which is in the \texttt{trade.mar.2007} data frame:
>
> <<echo=TRUE>>=
> library(tradeCosts)
> data(trade.mar.2007)
> head(trade.mar.2007)
> @
>
> -------------------------------------------------------------------------
>
> Here is the result of sweaving:
>
> Writing to file tradeCosts-article.tex
> Processing code chunks ...
>  1 : term verbatim
>  2 : echo term verbatim
> Loading required package: tools
>
> Attaching package: 'tradeCosts'
>
>
>         The following object(s) are masked from package:grDevices :
>
>          pdf
>
>  3 : echo term verbatim
>  4 : echo term verbatim
>  5 : term verbatim
>  6 : echo term verbatim
>  7 : term verbatim
>  8 : echo term verbatim
>  9 : echo term verbatim
> 10 : term verbatim
> 11 : echo term verbatim
> 12 : term verbatim
> 13 : echo term verbatim
> 14 : term verbatim
> 15 : term verbatim
> 16 : term verbatim
> 17 : echo term verbatim eps pdf
>
> Error:  chunk 17
> Error in function (classes, fdef, mtable)  :
>   unable to find an inherited method for function "pdf", for signature "missing"
>
> Execution halted
>
>
>
>
>
>> Thanks for the suggestions.
>>
>> John
>>
>>
>>> I also have a problem with the vignettes (note
>>> there are two) but as with you this works:
>>>
>>> Rcmd build --no-vignettes tradeCosts
>>>
>>> I don't have any special environment variables set for temporary
>>> directories and I use C:\Program Files\R\...
>>> for R.  I use Rcmd.bat and sweave.bat from batchfiles found at:
>>> http://batchfiles.googlecode.com
>>> which finds R in the registry so no paths need be set.
>>> I am on Vista but you seem to have SP1 which I don't
>>> have yet.
>>>
>>> I can build other packages so there
>>> is probably something that needs fixing in their vignettes.
>>>
>>> On Sat, Apr 19, 2008 at 7:52 AM, John Fox <[hidden email]> wrote:
>>>> Dear list members,
>>>>
>>>> I've encountered the following problem trying to build a package
>>> under
>>>> Windows Vista (SP1). The problem occurs with both R 2.6.2 and R 2.7.0
>>> RC
>>>> (from which this output was produced). The package builds just fine
>>> on my XP
>>>> (SP2) machine. Please see some further comments below.
>>>>
>>>> ---------- snip -------------
>>>>
>>>> Microsoft Windows [Version 6.0.6001]
>>>> Copyright (c) 2006 Microsoft Corporation.  All rights reserved.
>>>>
>>>> d:\R-packages>R CMD build tradeCosts
>>>> * checking for file 'tradeCosts/DESCRIPTION' ... OK
>>>> * preparing 'tradeCosts':
>>>> * checking DESCRIPTION meta-information ... OK
>>>> * installing the package to re-build vignettes
>>>> installing R.css in
>>> C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586
>>>>
>>>> ---------- Making package tradeCosts ------------
>>>>  adding build stamp to DESCRIPTION
>>>>  installing NAMESPACE file and metadata
>>>> Error in file(file, "r") : unable to open connection
>>>> Calls: <Anonymous> -> parseNamespaceFile -> parse -> file
>>>> In addition: Warning message:
>>>> In file(file, "r") :
>>>>  cannot open file
>>>> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCos
>>>> ts/NAMESPACE', reason 'Permission denied'
>>>> Execution halted
>>>> make[2]: *** [nmspace] Error 1
>>>> make[1]: *** [all] Error 2
>>>> make: *** [pkg-tradeCosts] Error 2
>>>> *** Installation of tradeCosts failed ***
>>>>
>>>> Removing
>>> 'C:/Users/JOHNFO~1/AppData/Local/Temp/Rinst602447586/tradeCosts'
>>>> * creating vignettes ... OK
>>>> * removing junk files
>>>> * checking for LF line-endings in source and make files
>>>> * checking for empty or unneeded directories
>>>> * building 'tradeCosts_0.3-0.tar.gz'
>>>>
>>>>
>>>> d:\R-packages>
>>>>
>>>> ---------- snip -------------
>>>>
>>>> I believe that the error is related to the vignette in the package,
>>> since I
>>>> can build packages without a vignette. Clearly there is a file-
>>> permission
>>>> problem but: (1) I'm using an account with administrator privileges;
>>> (2) R
>>>> is installed into c:\R (and the problem persists even when I install
>>> R into
>>>> d:\R); (3) the problem persists when I run the command window and R
>>> itself
>>>> as administrator, and when I turn off account controls; (4) the
>>> problems
>>>> persists when I reset the environment variables temp and tmp to
>>> d:\temp and
>>>> set the permissions to d:\temp so that all groups and users have full
>>>> control over that directory.
>>>>
>>>> I'm tempted to dump Vista but I've been trying to persist with it
>>> since most
>>>> people (e.g., my students) buying new Windows machines will be
>>> getting it.
>>>> Although I've read section 2.24 of the R for Windows FAQ, it's quite
>>>> possible that I've missed something of relevance there.
>>>>
>>>> Any help would be appreciated.
>>>>
>>>> Thanks in advance,
>>>>  John
>>>>
>>>> --------------------------------
>>>> John Fox, Professor
>>>> Department of Sociology
>>>> McMaster University
>>>> Hamilton, Ontario, Canada L8S 4M4
>>>> 905-525-9140x23604
>>>> http://socserv.mcmaster.ca/jfox
>>>>
>>>> ______________________________________________
>>>> [hidden email] mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Prof Brian Ripley
On Sun, 20 Apr 2008, Duncan Murdoch wrote:

> On 20/04/2008 8:43 AM, Gabor Grothendieck wrote:
>> There does seem to be some general problem associated with Sweave
>> and graphics when I try it on my Vista system with
>> [1] "R version 2.7.0 RC (2008-04-17 r45367)"

There is no evidence whatsoever of 'some general problem', and it is quite
specific to that package.  We've tested all the CRAN and BioC packages
with vignettes, and accounted for all the errors.

>> Using tradeCosts-article.Rnw from the tradeCosts package:
>>
>>     setwd(path.to.tradeCosts-article.Rnw)
>>     Sweave("tradeCosts-article.Rnw")
>>
>> appears to work properly; however, if we try it from the
>> command line:
>>
>>     R CMD Sweave tradeCosts-article.Rnw
>>
>> to simulate what happens when trying to build the package it
>> indicates that in chunk 2 that pdf is masked from grDevices.
>
> tradeCosts has its own pdf(), which is an S4 generic.  Once you have
> attached that package, the regular pdf() device driver is hidden.  So it
> looks as though running Sweave from the R console does the search in the
> intended way, but running it from R CMD Sweave finds the tradeCosts
> version of pdf() instead of the standard one.

Sweave does call grDevices::pdf explicitly.  But that's not the issue as

R --slave < tradeCosts-article.R

also fails at

Calls: plot ... barplot -> barplot.default -> par -> pdf -> <Anonymous>

So the issue is that pdf() is getting called because no device has been
opened, and "pdf" is the default device.  That seems quite reasonable to
me: if you create a function "pdf" high on the path it indicates that you
want that to be the default device.  (And the default device is used.)

If you want grDevices::pdf to be the default device, that is what you need
to specify (as written).

The solution is to open a device explicitly in the vignette, e.g. call
dev.new() before library(tradeCosts).

> I don't see why there's any difference here,

batch vs interactive.

> but utils (where Sweave lives) doesn't state that it depends on
> grDevices (which is where the standard pdf() comes from). However,
> fixing this is not enough to fix the error.

(That's intentional, as is the use of grDevices::pdf.)


> I see that tradeCosts doesn't declare any dependency on grDevices;
> fixing that also doesn't fix the problem.
>
> When tradeCosts creates the S4 generic for pdf(), it uses a signature
> that is inconsistent with the standard one; that might be the problem.
> However, I don't see how to fix it.  The docs for setGeneric suggest
> simply using
>
>  setGeneric("pdf")
>
> but that doesn't work:
>
> Loading required package: grDevices
> Loading required package: graphics
> Loading required package: stats
> Loading required package: tools
> Error in setGeneric("pdf") :
>   must supply a function skeleton, explicitly or via an existing function
>
> I don't know why setGeneric can't see pdf() in grDevices.  I think John
> Chambers is offline for a while, so this will likely have to wait.

If you did this in the package, that code is run without importing
grDevices.  If you do, it has a different complaint (that the signatures
differ).


--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Duncan Murdoch
On 20/04/2008 1:21 PM, Prof Brian Ripley wrote:

> On Sun, 20 Apr 2008, Duncan Murdoch wrote:
>
>> On 20/04/2008 8:43 AM, Gabor Grothendieck wrote:
>>> There does seem to be some general problem associated with Sweave
>>> and graphics when I try it on my Vista system with
>>> [1] "R version 2.7.0 RC (2008-04-17 r45367)"
>
> There is no evidence whatsoever of 'some general problem', and it is quite
> specific to that package.  We've tested all the CRAN and BioC packages
> with vignettes, and accounted for all the errors.
>
>>> Using tradeCosts-article.Rnw from the tradeCosts package:
>>>
>>>     setwd(path.to.tradeCosts-article.Rnw)
>>>     Sweave("tradeCosts-article.Rnw")
>>>
>>> appears to work properly; however, if we try it from the
>>> command line:
>>>
>>>     R CMD Sweave tradeCosts-article.Rnw
>>>
>>> to simulate what happens when trying to build the package it
>>> indicates that in chunk 2 that pdf is masked from grDevices.
>> tradeCosts has its own pdf(), which is an S4 generic.  Once you have
>> attached that package, the regular pdf() device driver is hidden.  So it
>> looks as though running Sweave from the R console does the search in the
>> intended way, but running it from R CMD Sweave finds the tradeCosts
>> version of pdf() instead of the standard one.
>
> Sweave does call grDevices::pdf explicitly.  But that's not the issue as
>
> R --slave < tradeCosts-article.R
>
> also fails at
>
> Calls: plot ... barplot -> barplot.default -> par -> pdf -> <Anonymous>
>
> So the issue is that pdf() is getting called because no device has been
> opened, and "pdf" is the default device.  That seems quite reasonable to
> me: if you create a function "pdf" high on the path it indicates that you
> want that to be the default device.  (And the default device is used.)

I think there may be another problem.  Running R on the Stangle output
is different than running Sweave, because Sweave knows that certain
chunks have fig=TRUE, and so it should set up the graphics device for
them.  I don't think there's a chunk in that file that does graphics
without declaring fig=TRUE, so the original Sweave run should succeed,
even if the run above fails.

So I still don't understand why in chunk 17 "pdf" is being used instead
of "grDevices::pdf".

> If you want grDevices::pdf to be the default device, that is what you need
> to specify (as written).
>
> The solution is to open a device explicitly in the vignette, e.g. call
> dev.new() before library(tradeCosts).
>
>> I don't see why there's any difference here,
>
> batch vs interactive.
>
>> but utils (where Sweave lives) doesn't state that it depends on
>> grDevices (which is where the standard pdf() comes from). However,
>> fixing this is not enough to fix the error.
>
> (That's intentional, as is the use of grDevices::pdf.)
>
>
>> I see that tradeCosts doesn't declare any dependency on grDevices;
>> fixing that also doesn't fix the problem.
>>
>> When tradeCosts creates the S4 generic for pdf(), it uses a signature
>> that is inconsistent with the standard one; that might be the problem.
>> However, I don't see how to fix it.  The docs for setGeneric suggest
>> simply using
>>
>>  setGeneric("pdf")
>>
>> but that doesn't work:
>>
>> Loading required package: grDevices
>> Loading required package: graphics
>> Loading required package: stats
>> Loading required package: tools
>> Error in setGeneric("pdf") :
>>   must supply a function skeleton, explicitly or via an existing function
>>
>> I don't know why setGeneric can't see pdf() in grDevices.  I think John
>> Chambers is offline for a while, so this will likely have to wait.
>
> If you did this in the package, that code is run without importing
> grDevices.  If you do, it has a different complaint (that the signatures
> differ).

I did this by adding grDevices to the Depends line in the package
DESCRIPTION.

I think we need to simplify this stuff. I was under the impression that
Depends implied Imports, and seeing the "Loading required" messages
makes me think that at the time setGeneric("pdf") was called (I put it
in the AllGenerics.R file), grDevices would at least be on the search
path.  I later put an explicit "library(grDevices)" ahead of the call to
setGeneric("pdf"), and that still didn't work.

So the problem is that our search strategy is too complicated.  I'd
expect if a function was visible to be executed (as pdf() was at that
point), then it should be visible to be used in setGeneric().  It
shouldn't matter if it is imported, or just on the search path:  we
should consistently see it or consistently not see it.  (I would
actually prefer the latter.  If you don't explicitly import it, then you
shouldn't be able to use it in package code.)

Duncan Murdoch

>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Prof Brian Ripley
On Sun, 20 Apr 2008, Duncan Murdoch wrote:

> On 20/04/2008 1:21 PM, Prof Brian Ripley wrote:
>> On Sun, 20 Apr 2008, Duncan Murdoch wrote:
>>
>>> On 20/04/2008 8:43 AM, Gabor Grothendieck wrote:
>>>> There does seem to be some general problem associated with Sweave
>>>> and graphics when I try it on my Vista system with
>>>> [1] "R version 2.7.0 RC (2008-04-17 r45367)"
>>
>> There is no evidence whatsoever of 'some general problem', and it is quite
>> specific to that package.  We've tested all the CRAN and BioC packages with
>> vignettes, and accounted for all the errors.
>>
>>>> Using tradeCosts-article.Rnw from the tradeCosts package:
>>>>
>>>>     setwd(path.to.tradeCosts-article.Rnw)
>>>>     Sweave("tradeCosts-article.Rnw")
>>>>
>>>> appears to work properly; however, if we try it from the
>>>> command line:
>>>>
>>>>     R CMD Sweave tradeCosts-article.Rnw
>>>>
>>>> to simulate what happens when trying to build the package it
>>>> indicates that in chunk 2 that pdf is masked from grDevices.
>>> tradeCosts has its own pdf(), which is an S4 generic.  Once you have
>>> attached that package, the regular pdf() device driver is hidden.  So it
>>> looks as though running Sweave from the R console does the search in the
>>> intended way, but running it from R CMD Sweave finds the tradeCosts
>>> version of pdf() instead of the standard one.
>>
>> Sweave does call grDevices::pdf explicitly.  But that's not the issue as
>>
>> R --slave < tradeCosts-article.R
>>
>> also fails at
>>
>> Calls: plot ... barplot -> barplot.default -> par -> pdf -> <Anonymous>
>>
>> So the issue is that pdf() is getting called because no device has been
>> opened, and "pdf" is the default device.  That seems quite reasonable to
>> me: if you create a function "pdf" high on the path it indicates that you
>> want that to be the default device.  (And the default device is used.)
>
> I think there may be another problem.  Running R on the Stangle output is
> different than running Sweave, because Sweave knows that certain chunks have
> fig=TRUE, and so it should set up the graphics device for them.  I don't
> think there's a chunk in that file that does graphics without declaring
> fig=TRUE, so the original Sweave run should succeed, even if the run above
> fails.
>
> So I still don't understand why in chunk 17 "pdf" is being used instead of
> "grDevices::pdf".

That's equally true of the example used in example(Sweave), and that puts
up a graphics device, just as this one does.

fig=TRUE asks for *additional* runs with devices set -- see the code in
makeRweaveLatexCodeRunner.  If options$eval is true

                 if(options$eval) err <- evalFunc(ce, options)

is run (and if it isn't options$eps and options$pdf are not reached).
Or look at ?RweaveLatex which says

      eval: logical ('TRUE'). If 'FALSE', the code chunk is not
           evaluated, and hence no text or graphical output produced.

Try

options(device="pdf")
example(Sweave)

and see what gets generated.

Or (as I had done), put options(device=grDevice::pdf) in the first chunk
of the tradeCosts example, and see what gets plotted in Rplots.pdf.

[...]


--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: package building problem under Windows Vista

Duncan Murdoch
On 20/04/2008 5:00 PM, Prof Brian Ripley wrote:

> On Sun, 20 Apr 2008, Duncan Murdoch wrote:
>
>> On 20/04/2008 1:21 PM, Prof Brian Ripley wrote:
>>> On Sun, 20 Apr 2008, Duncan Murdoch wrote:
>>>
>>>> On 20/04/2008 8:43 AM, Gabor Grothendieck wrote:
>>>>> There does seem to be some general problem associated with Sweave
>>>>> and graphics when I try it on my Vista system with
>>>>> [1] "R version 2.7.0 RC (2008-04-17 r45367)"
>>> There is no evidence whatsoever of 'some general problem', and it is quite
>>> specific to that package.  We've tested all the CRAN and BioC packages with
>>> vignettes, and accounted for all the errors.
>>>
>>>>> Using tradeCosts-article.Rnw from the tradeCosts package:
>>>>>
>>>>>     setwd(path.to.tradeCosts-article.Rnw)
>>>>>     Sweave("tradeCosts-article.Rnw")
>>>>>
>>>>> appears to work properly; however, if we try it from the
>>>>> command line:
>>>>>
>>>>>     R CMD Sweave tradeCosts-article.Rnw
>>>>>
>>>>> to simulate what happens when trying to build the package it
>>>>> indicates that in chunk 2 that pdf is masked from grDevices.
>>>> tradeCosts has its own pdf(), which is an S4 generic.  Once you have
>>>> attached that package, the regular pdf() device driver is hidden.  So it
>>>> looks as though running Sweave from the R console does the search in the
>>>> intended way, but running it from R CMD Sweave finds the tradeCosts
>>>> version of pdf() instead of the standard one.
>>> Sweave does call grDevices::pdf explicitly.  But that's not the issue as
>>>
>>> R --slave < tradeCosts-article.R
>>>
>>> also fails at
>>>
>>> Calls: plot ... barplot -> barplot.default -> par -> pdf -> <Anonymous>
>>>
>>> So the issue is that pdf() is getting called because no device has been
>>> opened, and "pdf" is the default device.  That seems quite reasonable to
>>> me: if you create a function "pdf" high on the path it indicates that you
>>> want that to be the default device.  (And the default device is used.)
>> I think there may be another problem.  Running R on the Stangle output is
>> different than running Sweave, because Sweave knows that certain chunks have
>> fig=TRUE, and so it should set up the graphics device for them.  I don't
>> think there's a chunk in that file that does graphics without declaring
>> fig=TRUE, so the original Sweave run should succeed, even if the run above
>> fails.
>>
>> So I still don't understand why in chunk 17 "pdf" is being used instead of
>> "grDevices::pdf".
>
> That's equally true of the example used in example(Sweave), and that puts
> up a graphics device, just as this one does.
>
> fig=TRUE asks for *additional* runs with devices set -- see the code in
> makeRweaveLatexCodeRunner.  If options$eval is true
>
>                  if(options$eval) err <- evalFunc(ce, options)
>
> is run (and if it isn't options$eps and options$pdf are not reached).

Thanks, that explains it.

Duncan Murdoch

> Or look at ?RweaveLatex which says
>
>       eval: logical ('TRUE'). If 'FALSE', the code chunk is not
>            evaluated, and hence no text or graphical output produced.
>
> Try
>
> options(device="pdf")
> example(Sweave)
>
> and see what gets generated.
>
> Or (as I had done), put options(device=grDevice::pdf) in the first chunk
> of the tradeCosts example, and see what gets plotted in Rplots.pdf.
>
> [...]
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel