[Rd] R_ext manual: type cast in C function registra tion

2010-01-07 Thread Simon Anders
Hi,

the Writing R extensions manual currently advises to register a .Call
function as follows:

   R_CallMethodDef callMethods[]  = {
   {myCall, myCall, 3},
   {NULL, NULL, 0}
   };

This produces a compiler warning, at least on my GCC, because the second
slot in the R_CallMethodDef is declared as DL_FUNC (which is declared as
'typedef void * (*DL_FUNC)();').

I'd suggest to change the example code in the manual to include an
explicit cast, i.e., 


   R_CallMethodDef callMethods[]  = {
   {myCall, (DL_FUNC) myCall, 3},
   {NULL, NULL, 0}
   };

in order to get rid of an unnecessary compiler warning.

Cheers
  Simon


+---
| Dr. Simon Anders, Dipl.-Phys.
| European Molecular Biology Laboratory (EMBL), Heidelberg
| office phone +49-6221-387-8632
| preferred (permanent) e-mail: sand...@fs.tum.de

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


[Rd] chooseCRANmirror() (PR#14179)

2010-01-07 Thread chrishold
Full_Name: Chris Evans
Version: 2.10.1
OS: Windows XP sp3
Submission from: (NULL) (86.159.235.204)


I was on leave and using a wifi internet connection in France and got connected,
launched R (2.10.1 on Windoze XPsp3) and tried to update my packages and got:

 chooseCRANmirror()
Error in m[, 1L] : incorrect number of dimensions

It took me a bit to realise that the message was coming up because the wifi
connection had dropped.  I know it's a small issue but is it possible to produce
a more informative error message. I can see a bodge of changing chooseCRANmirror
to:

function (graphics = getOption(menu.graphics)) 
{
if (!interactive()) 
stop(cannot choose a CRAN mirror non-interactively)
m - getCRANmirrors(all = FALSE, local.only = FALSE)
### bodge added here
if (ncol(m) != 8) stop(There was a problem with access to CRAN mirrors,
please check your internet connection)
### end of bodge
res - menu(m[, 1L], graphics, CRAN mirror)
if (res  0L) {
URL - m[res, URL]
repos - getOption(repos)
repos[CRAN] - gsub(/$, , URL[1L])
options(repos = repos)
}
invisible()
}
environment: namespace:utils

However, I'm sure you code gurus can do much better than that.

Many thanks for R: statistical wonderland, coding genius and a social movement
of which to be hugely proud!

Chris (Evans)

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


Re: [Rd] chooseCRANmirror() (PR#14179)

2010-01-07 Thread Prof Brian Ripley
Hmm, have you read getCRANmirrors?  It works gracefully if the 
connection is down, and has been tested quite a lot 


It seems you got a corrupt read from the URL: that's not reproducible 
and the place to deal with that is getCRANmirrors.


Please do use an informative subject line: it makes things *much* 
easier to find in archives.



On Wed, 6 Jan 2010, chrish...@psyctc.org wrote:


Full_Name: Chris Evans
Version: 2.10.1
OS: Windows XP sp3
Submission from: (NULL) (86.159.235.204)


I was on leave and using a wifi internet connection in France and got connected,
launched R (2.10.1 on Windoze XPsp3) and tried to update my packages and got:


chooseCRANmirror()

Error in m[, 1L] : incorrect number of dimensions

It took me a bit to realise that the message was coming up because the wifi
connection had dropped.  I know it's a small issue but is it possible to produce
a more informative error message. I can see a bodge of changing chooseCRANmirror
to:

function (graphics = getOption(menu.graphics))
{
   if (!interactive())
   stop(cannot choose a CRAN mirror non-interactively)
   m - getCRANmirrors(all = FALSE, local.only = FALSE)
   ### bodge added here
   if (ncol(m) != 8) stop(There was a problem with access to CRAN mirrors,
please check your internet connection)
   ### end of bodge
   res - menu(m[, 1L], graphics, CRAN mirror)
   if (res  0L) {
   URL - m[res, URL]
   repos - getOption(repos)
   repos[CRAN] - gsub(/$, , URL[1L])
   options(repos = repos)
   }
   invisible()
}
environment: namespace:utils

However, I'm sure you code gurus can do much better than that.

Many thanks for R: statistical wonderland, coding genius and a social movement
of which to be hugely proud!

Chris (Evans)

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] Creating RPMs for Packages

2010-01-07 Thread nashjc
This may get delayed as I am away from my usual mail system.

Since (thanks to Dirk and Charles) there is the cran2deb project giving us
most R packages in debian package format, could the alien package help?
See

http://www.linuxdocs.org/HOWTOs/RPM-for-Unix-HOWTO-8.html

John Nash

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


[Rd] Segfault in GetNewPage, memory.c.

2010-01-07 Thread Guillaume Yziquel

Hello.

I'm still working on my OCaml-R binding and I get a segfault in the 
GetNewPage() function of memory.c.


For the record, the OCaml-R binding seems to work fine with OCaml 
bytecode. The segfault here is the main issue I have with OCaml native 
code. OCaml-R can be found on the following links.


Source code:

http://yziquel.homelinux.org/gitweb/?p=ocaml-r.git;a=summary
http://svn.gna.org/viewcvs/ocaml-r/branches/yziquel/

Debian packages for amd64:

http://yziquel.homelinux.org/debian/pool/main/o/ocaml-r/

Some documentation (not entirely up to date...):

http://yziquel.homelinux.org/topos/api/ocaml-r/R.html
http://yziquel.homelinux.org/topos/debian-ocamlr.html

Back to my segfault:


yziq...@seldon:~/git/ocaml-finquote$ gdb -silent -d 
/home/yziquel/src/r-base-2.10.1/src/main/ _build/test/test.native
Reading symbols from 
/home/yziquel/git/ocaml-finquote/_build/test/test.native...(no debugging 
symbols found)...done.
(gdb) run
Starting program: /home/yziquel/git/ocaml-finquote/_build/test/test.native 
[Thread debugging using libthread_db enabled]


Program received signal SIGSEGV, Segmentation fault.
GetNewPage (node_class=1) at memory.c:657
657 SNAP_NODE(s, base);
(gdb) backtrace
#0  GetNewPage (node_class=1) at memory.c:657
#1  0x77993c24 in Rf_allocVector (type=16, length=1) at memory.c:2030
#2  0x77981070 in Rf_mkString (s=0x6ae548 require(quantmod)) at 
../../src/include/Rinlinedfuns.h:582
#3  0x0047d63f in parse_sexp ()
#4  0x00498990 in caml_c_call ()
#5  0x77fb37e8 in ?? ()
#6  0x00423aa0 in camlQuantmod__entry ()
#7  0x77fb5820 in ?? ()
#8  0x00421649 in caml_program ()
#9  0x0012697e in ?? ()
#10 0x004989e6 in caml_start_program ()
#11 0x in ?? ()
(gdb) 


As OCaml is compiled to native machine code, it has its own ABI, and 
this is why you do not see much traceback on the OCaml side.


The segfault happens at the moment that we try to do 
require(quantmod). The R interpreter is already up an running when we 
execute this R command.


I wish to point out that this same piece of code works fine in OCaml 
bytecode, which sorts of implies that my C glue is rather OK.


From source code, the execution goes this way:


  let () = ignore (R.eval_string require(quantmod))


We're simply trying to evaluate the require(quantmod) string in R.


let eval_string s = eval_langsxp (parse_sexp s)


eval_string calls


external parse_sexp : string - sexp = parse_sexp


which access the C glue code wrapping R_ParseVector.


CAMLprim value parse_sexp (value s) {
  CAMLparam1(s);
  SEXP text ;
  SEXP pr ;
  ParseStatus status;
  PROTECT(text = mkString(String_val(s)));
  PROTECT(pr=R_ParseVector(text, 1, status, R_NilValue));
  UNPROTECT(2);
  switch (status) {
case PARSE_OK:
 break;
case PARSE_INCOMPLETE:
case PARSE_EOF:
  caml_raise_with_string(*caml_named_value(Parse_incomplete), 
(String_val(s)));
case PARSE_NULL:
case PARSE_ERROR:
  caml_raise_with_string(*caml_named_value(Parse_error), (String_val(s)));
  }
  CAMLreturn(Val_sexp(VECTOR_ELT(pr,0)));
}


But before calling ParseVector, it allocates an R string with the command.


  PROTECT(text = mkString(String_val(s)));


It is this call to mkString which gives the segfault. String_val 
essentially is a macro that casts an OCaml value to a char *.



yziq...@seldon:~/git/ocaml-finquote$ gdb -silent -d 
/home/yziquel/src/r-base-2.10.1/src/main/ _build/test/test.native
Reading symbols from 
/home/yziquel/git/ocaml-finquote/_build/test/test.native...(no debugging 
symbols found)...done.
(gdb) set breakpoint pending on
(gdb) break Rf_mkString
Breakpoint 1 at 0x420858
(gdb) run
Starting program: /home/yziquel/git/ocaml-finquote/_build/test/test.native 
[Thread debugging using libthread_db enabled]


Breakpoint 1, Rf_mkString (s=0x6ae548 require(quantmod)) at 
../../src/include/Rinlinedfuns.h:582
582 PROTECT(t = allocVector(STRSXP, 1));
(gdb) step
579 {
(gdb) 
582	PROTECT(t = allocVector(STRSXP, 1));
(gdb) 
Rf_allocVector (type=16, length=1) at memory.c:1916

1916{
(gdb) next
1924if (length  0 )
(gdb) 
1928	switch (type) {
(gdb) 
1978		if (length = 0)
(gdb) 
1984		size = PTR2VEC(length);
(gdb) 
2000	if (size = NodeClassSize[1]) {
(gdb) 
2017	old_R_VSize = R_VSize;
(gdb) 
2020	if (FORCE_GC || NO_FREE_NODES() || VHEAP_FREE()  alloc_size) {
(gdb) 
2017	old_R_VSize = R_VSize;
(gdb) 
2020	if (FORCE_GC || NO_FREE_NODES() || VHEAP_FREE()  alloc_size) {
(gdb) 
2028	if (size  0) {
(gdb) 
2029		if (node_class  NUM_SMALL_NODE_CLASSES) {
(gdb) 
2030		CLASS_GET_FREE_NODE(node_class, s);
(gdb) 


Program received signal SIGSEGV, Segmentation fault.
GetNewPage (node_class=1) at memory.c:657
657 SNAP_NODE(s, base);
(gdb) 


So CLASS_GET_FREE_NODE is #defined in memory.c as:


#define CLASS_GET_FREE_NODE(c,s) do { 

Re: [Rd] Human-style sort() of alphanum strings?

2010-01-07 Thread Henrik Bengtsson
Follow up/bug:

mixedsort() gets confused when there are periods in the string(s);

   print(gtools::mixedsort(a))
[1] a
   print(gtools::mixedsort(a.))
[1] a. NA
   print(gtools::mixedsort(a.b))
[1] a.b NANA
   print(gtools::mixedsort(a.b.))
[1] a.b. NA NA NA
   print(gtools::mixedsort(a.b.c))
[1] a.b.c NA  NA  NA  NA
   print(gtools::mixedsort(a.b.c.))
[1] a.b.c. NA   NA   NA   NA   NA

Is the '.' trigger an incorrect interpretation of a number?

/Henrik

On Tue, Jan 5, 2010 at 3:48 PM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 See mixedsort in gtools.  Also on http://gsubfn.googlecode.com see
 mixsort example in the section starting ### more examples

 On Tue, Jan 5, 2010 at 6:34 PM, Henrik Bengtsson h...@stat.berkeley.edu 
 wrote:
 I know it is fairly easy to implement (though not always well
 defined), but is there an existing sort function out there that takes
 alphanum strings and sort them in a human fashion?  For example,
 instead of:

 z1.doc z10.doc z100.doc z101.doc z11.doc z2.doc

 it should out put:

 z1.doc z2.doc z10.doc z11.doc z100.doc z101.doc

 (from http://www.davekoelle.com/alphanum.html).

 /Henrik

 __
 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] Human-style sort() of alphanum strings?

2010-01-07 Thread Gabor Grothendieck
I had suggested two possibilities, not just mixedsort.  The other was mixsort:

 mixsort(a.b.c)
[1] a.b.c
 print(mixsort(a))
[1] a
 print(mixsort(a.))
[1] a.
 print(mixsort(a.b))
[1] a.b
 print(mixsort(a.b.))
[1] a.b.
 print(mixsort(a.b.c))
[1] a.b.c
 print(mixsort(a.b.c.))
[1] a.b.c.


On Thu, Jan 7, 2010 at 6:50 PM, Henrik Bengtsson h...@stat.berkeley.edu wrote:
 Follow up/bug:

 mixedsort() gets confused when there are periods in the string(s);

   print(gtools::mixedsort(a))
 [1] a
   print(gtools::mixedsort(a.))
 [1] a. NA
   print(gtools::mixedsort(a.b))
 [1] a.b NA    NA
   print(gtools::mixedsort(a.b.))
 [1] a.b. NA     NA     NA
   print(gtools::mixedsort(a.b.c))
 [1] a.b.c NA      NA      NA      NA
   print(gtools::mixedsort(a.b.c.))
 [1] a.b.c. NA       NA       NA       NA       NA

 Is the '.' trigger an incorrect interpretation of a number?

 /Henrik

 On Tue, Jan 5, 2010 at 3:48 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 See mixedsort in gtools.  Also on http://gsubfn.googlecode.com see
 mixsort example in the section starting ### more examples

 On Tue, Jan 5, 2010 at 6:34 PM, Henrik Bengtsson h...@stat.berkeley.edu 
 wrote:
 I know it is fairly easy to implement (though not always well
 defined), but is there an existing sort function out there that takes
 alphanum strings and sort them in a human fashion?  For example,
 instead of:

 z1.doc z10.doc z100.doc z101.doc z11.doc z2.doc

 it should out put:

 z1.doc z2.doc z10.doc z11.doc z100.doc z101.doc

 (from http://www.davekoelle.com/alphanum.html).

 /Henrik

 __
 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] Human-style sort() of alphanum strings?

2010-01-07 Thread Henrik Bengtsson
Thanks, and sorry - I missed those two missing letter ed and though
you only refer to that URL for extra example code.  mixsort() does it
for me.

/H

On Thu, Jan 7, 2010 at 3:50 PM, Henrik Bengtsson h...@stat.berkeley.edu wrote:
 Follow up/bug:

 mixedsort() gets confused when there are periods in the string(s);

   print(gtools::mixedsort(a))
 [1] a
   print(gtools::mixedsort(a.))
 [1] a. NA
   print(gtools::mixedsort(a.b))
 [1] a.b NA    NA
   print(gtools::mixedsort(a.b.))
 [1] a.b. NA     NA     NA
   print(gtools::mixedsort(a.b.c))
 [1] a.b.c NA      NA      NA      NA
   print(gtools::mixedsort(a.b.c.))
 [1] a.b.c. NA       NA       NA       NA       NA

 Is the '.' trigger an incorrect interpretation of a number?

 /Henrik

 On Tue, Jan 5, 2010 at 3:48 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 See mixedsort in gtools.  Also on http://gsubfn.googlecode.com see
 mixsort example in the section starting ### more examples

 On Tue, Jan 5, 2010 at 6:34 PM, Henrik Bengtsson h...@stat.berkeley.edu 
 wrote:
 I know it is fairly easy to implement (though not always well
 defined), but is there an existing sort function out there that takes
 alphanum strings and sort them in a human fashion?  For example,
 instead of:

 z1.doc z10.doc z100.doc z101.doc z11.doc z2.doc

 it should out put:

 z1.doc z2.doc z10.doc z11.doc z100.doc z101.doc

 (from http://www.davekoelle.com/alphanum.html).

 /Henrik

 __
 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