Re: [Rd] NEWS file (was faqs)

2007-11-16 Thread Prof Brian Ripley
On Thu, 15 Nov 2007, Simon Urbanek wrote:


 On Nov 15, 2007, at 10:53 AM, Duncan Murdoch wrote:

 On 11/15/2007 9:57 AM, Simon Urbanek wrote:
 On Nov 14, 2007, at 11:55 PM, Gabor Grothendieck wrote:
 inst/NEWS would have the advantage of consistency with R itself
 which also has a NEWS file.

 I vote for NEWS for reasons above plus because that's what I use in
 my  packages already ;).
 IMHO it should be installed automatically if present, i.e. it
 shouldn't be necessary to have it in inst/NEWS, just plain NEWS
 should  suffice.

 And you're volunteering to make that change?


 Yup, in R-devel now (43464). However, there are other candidate files
 as well and we don't do anything with the NEWS file just yet ... any
 further ideas?

We've recommended inst/NEWS for some time (some people are late to this 
party), and tens of packages have it. However, a further tens of packages 
have a top-level NEWS, and I would assume that (at least some of) the 
authors were deliberately not installing it and so will now need to rename 
it.

I think the writeup needs to make clear what happens if you have both NEWS 
and inst/NEWS (some packages do).

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
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, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] NEWS file (was faqs)

2007-11-16 Thread friedrich . leisch
 On Fri, 16 Nov 2007 10:20:36 + (GMT),
 Prof Brian Ripley (PBR) wrote:

   On Thu, 15 Nov 2007, Simon Urbanek wrote:
   
   On Nov 15, 2007, at 10:53 AM, Duncan Murdoch wrote:
   
   On 11/15/2007 9:57 AM, Simon Urbanek wrote:
   On Nov 14, 2007, at 11:55 PM, Gabor Grothendieck wrote:
   inst/NEWS would have the advantage of consistency with R itself
   which also has a NEWS file.
   
   I vote for NEWS for reasons above plus because that's what I use in
   my  packages already ;).
   IMHO it should be installed automatically if present, i.e. it
   shouldn't be necessary to have it in inst/NEWS, just plain NEWS
   should  suffice.
   
   And you're volunteering to make that change?
   
   
   Yup, in R-devel now (43464). However, there are other candidate files
   as well and we don't do anything with the NEWS file just yet ... any
   further ideas?

   We've recommended inst/NEWS for some time (some people are late to this 
   party), and tens of packages have it. However, a further tens of packages 
   have a top-level NEWS, and I would assume that (at least some of) the 
   authors were deliberately not installing it and so will now need to rename 
   it.

   I think the writeup needs to make clear what happens if you have both NEWS 
   and inst/NEWS (some packages do).

As most having both are by me I also checked the rest: In all cases
on CRAN they are identical copies. I have a soft link in all my
packages from inst/NEWS to top level (such that it gets installed, but
it is also easily found in the sources).

If we install the top-level NEWS file I would remove the link (but as
Brian said, we've been there before).

Best,
Fritz

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] re sponses to issues on r-devel

2007-11-16 Thread Ben Bolker


  I'm probably going to get in trouble for this, but ... 

  What is the best way to get 'important' issues resolved
by R-core?  There is a category of 'issues' (I won't call
them bugs or problems, although arguably they are so)
that appear on R-devel and sink without ever receiving an
explicit acknowledgment.  These problems tend to be:
 * non-trivial 
 * outside of the main current interests (perhaps) of R-core

  I'm thinking in this case of Petr Savicky's series of posts

http://www.nabble.com/bug-in-detection-of-zero-state-for-Mersenne-Twister-%28PR-10362%29-tf4670916.html#a13343487
http://www.nabble.com/initial-scrambling-of-seed-in-do_setseed---RNG_Init-tf4504008.html#a12845234
http://www.nabble.com/all-zeroes-in-Mersenne-Twister-state-may-remain-undetected-tf4626354.html#a13210502
http://www.nabble.com/predictable-bit-patterns-in-runif%28n%29-shortly-after-set.seed-tf4641681.html#a13257396

all between Sept 23 and October 15.   One of these was posted as a bug, but
the rest are just
ideas.  However, they are very thoroughly documented ideas (with suggested
patches),
and it would be a shame if they fell between the cracks.  They might be on
R-core's to do list already  -- or
someone may have replied off-list -- or R-core might have read the posts and
decided
that they are not worth worrying about -- or R-core might go through the
archives
looking for these kinds of unresolved issues from time to time.

   Arguably the best solution to this kind of problem is just persistence by
the 'R-cortex' (OED:
 {dag}1. fig. The external part; the outer shell or husk. Obs.) [by which I
mean the people like
Petr who are capable of finding, diagnosing and creating useful patches],
re-posting
to R-devel every month or so if issues remain unresolved.  My *personal*
feeling
is that posting these kinds of issues as bugs, where they can be remembered
and dealt with,
is a good idea, but I'm prepared to be shouted down ...

  Is this a problem?  Is there a solution?

   (Please don't blame Petr for these comments, I'm just using his ideas as
an example)

   cheers
Ben Bolker
-- 
View this message in context: 
http://www.nabble.com/responses-to-issues-on-r-devel-tf4806780.html#a13752138
Sent from the R devel mailing list archive at Nabble.com.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Returning vectors of two different data types back to R environment (from C).

2007-11-16 Thread Charles Danko
Hello,

Quick question.

I have written a C function - I would like to make it return two vectors to
the R environment - one STRSXP vector, and one INTSXP vector.  Is this
possible/ easy to do using the API?

I looked, but could not find the answer to this  question in the Writing R
Extensions guide.

Thanks very much for your help!
Charles

[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Returning vectors of two different data types back to R environment (from C).

2007-11-16 Thread Barry Rowlingson
Charles Danko wrote:
 Hello,
 
 Quick question.
 
 I have written a C function - I would like to make it return two vectors to
 the R environment - one STRSXP vector, and one INTSXP vector.  Is this
 possible/ easy to do using the API?
 
 I looked, but could not find the answer to this  question in the Writing R
 Extensions guide.

  How does any R function return two different-typed values back to its 
caller? With a list - like list(foo=1,bar='baz'). Construct an R list in 
your C code and return that... R Extensions should tell you how!

Barry

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Returning vectors of two different data types back to R environment (from C).

2007-11-16 Thread Roger Bivand
On Fri, 16 Nov 2007, Charles Danko wrote:

 Hello,

 Quick question.

 I have written a C function - I would like to make it return two vectors to
 the R environment - one STRSXP vector, and one INTSXP vector.  Is this
 possible/ easy to do using the API?

 I looked, but could not find the answer to this  question in the Writing R
 Extensions guide.

Put them in a list? The SEXP function in the .Call() interface then 
returns a list wich you unpack on the R side. There are plenty of examples 
in the base code and in numerous contributed packages.


 Thanks very much for your help!
 Charles

   [[alternative HTML version deleted]]

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] C/C++ 'assert' should not be used in R packages

2007-11-16 Thread Henrik Bengtsson
On Nov 10, 2007 1:27 PM, Simon Urbanek [EMAIL PROTECTED] wrote:


 On Nov 10, 2007, at 1:05 PM, Duncan Murdoch wrote:

  On 10/11/2007 1:00 PM, Duncan Temple Lang wrote:
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
 
 
  Duncan Murdoch wrote:
  Prof Brian Ripley wrote:
  Please don't use 'assert' in R packages.  If called, this means
  that an
  error in your code aborts the whole R process, including your
  user's work.
  I see several R packages doing this, and one of them called
  'assert' on me
  earlier in the week.
 
  I partly disagree about this.  If assert() is triggered, it clearly
  indicates a bug in the package.  If it just generated an R error,
  most
  users would ignore it, and not report it to the package maintainer.
 
  It may well be that when an assertion fails, none of the subsequent
  calculations are reliable, in which case returning control to the
  user
  could result in data corruption.  That's worse than losing a
  session,
  because at least when you lose a session, you know it.
 
  Could we write our own implementation of assert() that displays an R
  error and unloads the package?  I think I could do something like
  that
  in Windows by calling FreeLibrary to unload the DLL, but I'd
  prefer a
  cross-platform solution.
 
  I am not sure why you think we need to discard the DLL.
 
  The package author has asserted that it is no longer safe to run.
  They are shutting down R, and Brian finds that too extreme.
 

 Me too. A package should never intentionally close the R session. If
 it does, it is a very severe design bug in the package (IMHO).
 Anything you use assert for can be gracefully handled (as opposed to
 let's say a segfault), so there is no excuse for killing the whole
 process at all (deliberately wiping all user's work is rude to put it
 mildly).

Oh, I normally try to wipe the harddrive too when I'm at it ;)

/H

 Even if it might be unsafe to run anything, I'd still want
 to attempt to save my data.

 Cheers,
 Simon



  What if we want to access variables and routines merely to find out
  the resulting state after the assert().
  And it is not clear whether you mean any subsequent calculations
  or any subsequent calculations using code within this DLL
  might be unreliable.
 
  How could I know why a package author decided a shutdown is
  needed?  It
  depends on the author.
 
 
  But regardless of that and the assumption that users will ignore this
  error, why would you want to call FreeLibrary? Since R has induced
  the
  DLL to be loaded either directly or indirectly, R holds a handle
  to the
  DLL. If you don't use R's cross-platform facilities for releasing the
  DLL (either at the R or C-level), you will corrupt the session,
  specifically in the list of assumed-live DLLs.
 
  As I said, I'd prefer a cross-platform solution.
 
  Duncan Murdoch
 
   D.
 
 
  We provide 'error': please do use it to return control to the
  user when
  your code misbehaves.
 
  Similarly 'exit' and 'abort' should never be used in R packages.
 
 
  Sometimes it is not under your control: I sometimes see an rgl
  failure at
 
  R: indirect_vertex_array.c:659: emit_DrawArrays_old: Assertion
  `elements_per_request = count' failed.
 
  that is coming from the Mesa GL libraries.
 
  I'd say that's a bug, either in Mesa GL or in rgl.  If you can
  make it
  reproducible, I'll try to track it down.
 
  Duncan Murdoch
 
  __
  R-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-devel
  -BEGIN PGP SIGNATURE-
  Version: GnuPG v1.4.7 (Darwin)
  Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
  iD8DBQFHNfHA9p/Jzwa2QP4RAo2BAJkB5QaFLOW5fcR6QE9JSXpIWAcEUwCggMYK
  2WBnl5jDgTUayU5wk8hnQj4=
  =91by
  -END PGP SIGNATURE-
 
  __
  R-devel@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-devel
 
 

 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel


__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Returning vectors of two different data types back to R environment (from C).

2007-11-16 Thread statmobile
On Fri, Nov 16, 2007 at 03:49:09PM -0500, Charles Danko wrote:
 Hello,
 
 Quick question.
 
 I have written a C function - I would like to make it return two vectors to
 the R environment - one STRSXP vector, and one INTSXP vector.  Is this
 possible/ easy to do using the API?
 
 I looked, but could not find the answer to this  question in the Writing R
 Extensions guide.

Yes, it's really quite reasonable to do, although it's not documented
in detail in the R-extensions manual.  As stated earlier, this will
only work with .Call and SEXP functions where you can handle R objects
within C.  

In Section 5.9 Evaluating R expressions in C it has an example using
lists in C.  Basically, lists are VECSXP objects so you can search for
that in R-exts.

Also, I would recommend looking at 5.7.6 Handling lists and the
function: 

SEXP getListElement(SEXP list, char *str)

You should look for that, and then grep the source files for
examples.  If you don't have grep to search the files, then I would
recommend the R gonzui site:

http://rgonzui.nakama.ne.jp/

Personally, I found the source code for det() to be a useful example,
you can search for that on R gonzui.

Good Luck

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Returning vectors of two different data types back to R environment (from C).

2007-11-16 Thread Oleg Sklyar
SEXP x,y,res;
PROTECT(res = allocVector(VECSXP, 2));
SET_VECTOR_ELT(res, 0, x = allocVector(REALSXP, 20)); 
SET_VECTOR_ELT(res, 1, y = allocVector(INTSXP, 10)); 
// code with x,y goes here

UNPROTECT(1);
return res;

On Fri, 2007-11-16 at 15:49 -0500, Charles Danko wrote:
 Hello,
 
 Quick question.
 
 I have written a C function - I would like to make it return two vectors to
 the R environment - one STRSXP vector, and one INTSXP vector.  Is this
 possible/ easy to do using the API?
 
 I looked, but could not find the answer to this  question in the Writing R
 Extensions guide.
 
 Thanks very much for your help!
 Charles
 
   [[alternative HTML version deleted]]
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] faqs

2007-11-16 Thread Gabor Grothendieck
On Nov 15, 2007 10:51 AM, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 On Nov 15, 2007 9:57 AM, Simon Urbanek [EMAIL PROTECTED] wrote:
 
  On Nov 14, 2007, at 11:55 PM, Gabor Grothendieck wrote:
 
   inst/NEWS would have the advantage of consistency with R itself
   which also has a NEWS file.
  
 
  I vote for NEWS for reasons above plus because that's what I use in my
  packages already ;).
  IMHO it should be installed automatically if present, i.e. it
  shouldn't be necessary to have it in inst/NEWS, just plain NEWS should
  suffice.
 

 I agree that that would be desirable.

Also it would be nice if the HTML files here:

http://cran.r-project.org/src/contrib/Descriptions/

each had a link to the NEWS file so one could get the news on a
package prior to
installing it.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel