Re: [R] Tidying up code - Warning message: deparse may be incomplete

2008-08-29 Thread Duncan Murdoch

On 28/08/2008 10:46 AM, Marie Pierre Sylvestre wrote:

Dear R users,

I am currently writing a R package and to do so I am following the
guidelines in manual 'Writing R extensions'.

In Section 3.1, it is suggested to tidy up the code using a file
containing the following:
options(keep.source = FALSE)
source(myfuns..R)
dump(ls(all = TRUE), file = new.myfuns.R)

I have done this for my own packages and although it runs, I get several
warnings of the type:

Warning message:
In dump(ls(all = TRUE), file = PermAlgo.R) : deparse may be incomplete

I am clueless as to what this means.

Even if I try to tidy only one function from my code, I get the warning.


E.g. the file lala.R contains only this:
partialHazards - function(t, v, covArray, betas){   exp( covArray[v,t,]
%*% betas ) }

the file tidylala.R contains:

options(keep.source = FALSE)
source(lala.R)
dump(ls(all = TRUE), file = newlala.R)

On Linux I run:

R --vanilla  tidylala.R  


Then I obtain:

Warning message:
In dump(ls(all = TRUE), file = newlala.R) : deparse may be incomplete

The file newlala.R looks like this:

`partialHazards` -
function (t, v, covArray, betas)
{
exp(covArray[v, t, ] %*% betas)
}

What does the warning mean? Can I simply ignore it?


I've now taken a look, and this really was a bug.  source() was 
partially ignoring options(keep.source = FALSE), and this confused 
dump().  I've fixed it in R-patched.


I've also clarified the advice about tidying up code, by adding a 
warning that following it will delete all of your comments.  I think 
you're better off writing it in a tidy way in the first place, or using 
a smart editor to reformat it.  R retains enough information to write a 
code prettifier that preserves comments, but I don't know of one.


Duncan Murdoch

__
R-help@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.


Re: [R] Tidying up code - Warning message: deparse may be incomplete

2008-08-29 Thread Martin Maechler
 DM == Duncan Murdoch [EMAIL PROTECTED]
 on Fri, 29 Aug 2008 08:36:12 -0400 writes:

DM On 28/08/2008 10:46 AM, Marie Pierre Sylvestre wrote:
 Dear R users,
 
 I am currently writing a R package and to do so I am following the
 guidelines in manual 'Writing R extensions'.
 
 In Section 3.1, it is suggested to tidy up the code using a file
 containing the following:
 options(keep.source = FALSE)
 source(myfuns..R)
 dump(ls(all = TRUE), file = new.myfuns.R)
 
 I have done this for my own packages and although it runs, I get several
 warnings of the type:
 
 Warning message:
 In dump(ls(all = TRUE), file = PermAlgo.R) : deparse may be incomplete
 
 I am clueless as to what this means.
 
 Even if I try to tidy only one function from my code, I get the warning.
 
 
 E.g. the file lala.R contains only this:
 partialHazards - function(t, v, covArray, betas){   exp( covArray[v,t,]
 %*% betas ) }
 
 the file tidylala.R contains:
 
 options(keep.source = FALSE)
 source(lala.R)
 dump(ls(all = TRUE), file = newlala.R)
 
 On Linux I run:
 
 R --vanilla  tidylala.R  
 
 Then I obtain:
 
 Warning message:
 In dump(ls(all = TRUE), file = newlala.R) : deparse may be incomplete
 
 The file newlala.R looks like this:
 
 `partialHazards` -
 function (t, v, covArray, betas)
 {
 exp(covArray[v, t, ] %*% betas)
 }
 
 What does the warning mean? Can I simply ignore it?

DM I've now taken a look, and this really was a bug.  source() was 
DM partially ignoring options(keep.source = FALSE), and this confused 
DM dump().  I've fixed it in R-patched.

DM I've also clarified the advice about tidying up code, by adding a 
DM warning that following it will delete all of your comments.  I think 
DM you're better off writing it in a tidy way in the first place, or using 
DM a smart editor to reformat it.  R retains enough information to write a 
DM code prettifier that preserves comments, but I don't know of one.

I strongly agree with your last paragraph,
and I have always thought that we should recommend using
R-aware editors rather than  dump() nowadays ...
but then I thought that I've been biased at all times, being a
co-developer of ESS, authoring its M-x ess-fix-miscellaneous
(and more), and also the author of a (non public) Emacs lisp
file called 'R-stylepolice.el' as early as in 1999.

Martin Maechler

DM Duncan Murdoch

__
R-help@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.


Re: [R] Tidying up code - Warning message: deparse may be incomplete

2008-08-29 Thread Peter Dalgaard
Martin Maechler wrote:
 I strongly agree with your last paragraph,
 and I have always thought that we should recommend using
 R-aware editors rather than  dump() nowadays ...
 but then I thought that I've been biased at all times, being a
 co-developer of ESS, authoring its M-x ess-fix-miscellaneous
 (and more), and also the author of a (non public) Emacs lisp
 file called 'R-stylepolice.el' as early as in 1999.

   
BTW: Has there been any progress on turning the highlighting _off_ in
iESS and transcript mode? The highlighted for and in make me crazy...

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@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.


[R] Tidying up code - Warning message: deparse may be incomplete

2008-08-28 Thread Marie Pierre Sylvestre
Dear R users,

I am currently writing a R package and to do so I am following the
guidelines in manual 'Writing R extensions'.

In Section 3.1, it is suggested to tidy up the code using a file
containing the following:
options(keep.source = FALSE)
source(myfuns..R)
dump(ls(all = TRUE), file = new.myfuns.R)

I have done this for my own packages and although it runs, I get several
warnings of the type:

Warning message:
In dump(ls(all = TRUE), file = PermAlgo.R) : deparse may be incomplete

I am clueless as to what this means.

Even if I try to tidy only one function from my code, I get the warning.


E.g. the file lala.R contains only this:
partialHazards - function(t, v, covArray, betas){   exp( covArray[v,t,]
%*% betas ) }

the file tidylala.R contains:

options(keep.source = FALSE)
source(lala.R)
dump(ls(all = TRUE), file = newlala.R)

On Linux I run:

R --vanilla  tidylala.R  

Then I obtain:

Warning message:
In dump(ls(all = TRUE), file = newlala.R) : deparse may be incomplete

The file newlala.R looks like this:

`partialHazards` -
function (t, v, covArray, betas)
{
exp(covArray[v, t, ] %*% betas)
}

What does the warning mean? Can I simply ignore it?

thanks,

MP

__
R-help@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.


Re: [R] Tidying up code - Warning message: deparse may be incomplete

2008-08-28 Thread Duncan Murdoch

On 28/08/2008 10:46 AM, Marie Pierre Sylvestre wrote:

Dear R users,

I am currently writing a R package and to do so I am following the
guidelines in manual 'Writing R extensions'.

In Section 3.1, it is suggested to tidy up the code using a file
containing the following:
options(keep.source = FALSE)
source(myfuns..R)
dump(ls(all = TRUE), file = new.myfuns.R)

I have done this for my own packages and although it runs, I get several
warnings of the type:

Warning message:
In dump(ls(all = TRUE), file = PermAlgo.R) : deparse may be incomplete

I am clueless as to what this means.

Even if I try to tidy only one function from my code, I get the warning.


E.g. the file lala.R contains only this:
partialHazards - function(t, v, covArray, betas){   exp( covArray[v,t,]
%*% betas ) }

the file tidylala.R contains:

options(keep.source = FALSE)
source(lala.R)
dump(ls(all = TRUE), file = newlala.R)

On Linux I run:

R --vanilla  tidylala.R  


Then I obtain:

Warning message:
In dump(ls(all = TRUE), file = newlala.R) : deparse may be incomplete

The file newlala.R looks like this:

`partialHazards` -
function (t, v, covArray, betas)
{
exp(covArray[v, t, ] %*% betas)
}

What does the warning mean? Can I simply ignore it?


The warning means that you may have lost some information, i.e. sourcing 
newlala.R won't produce the same thing as sourcing lala.R.  I think in 
your case, there's no loss, so it's a bug, but I don't have time to 
track down why you're getting it.


Duncan Murdoch

__
R-help@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.