[Rd] CXXR: Refactoring the R interpreter into C++

2008-02-29 Thread Andrew Runnalls
For a while now I have been working on a modified, but so far as
possible fully functional, version of R in which the interpreter is
progressively refactored (reengineered) from C to C++.  The work is
still at an early stage, but I think that sufficient progress has now
been made for it to be of interest to some readers of this list.

Further information is at http://www.cs.kent.ac.uk/projects/cxxr

Andrew Runnalls

-- 
Dr Andrew Runnalls,
Computing Laboratory,
University of Kent,
CANTERBURY CT2 7NF, UK

Tel: (0)1227 823821

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


Re: [Rd] Warnings generated by log2()/log10() are really large/t

2008-02-29 Thread Martin Maechler
 TH == Ted Harding [EMAIL PROTECTED]
 on Wed, 27 Feb 2008 14:36:05 - (GMT) writes:

TH On 27-Feb-08 13:39:47, Gabor Grothendieck wrote:
 On Wed, Feb 27, 2008 at 5:50 AM, Henrik Bengtsson
 [EMAIL PROTECTED] wrote:
 On Wed, Feb 27, 2008 at 12:56 AM, Prof Brian Ripley
 [EMAIL PROTECTED] wrote:
  On Wed, 27 Feb 2008, Martin Maechler wrote:
 
Thank you Henrik,
   
HenrikB == Henrik Bengtsson [EMAIL PROTECTED]
on Tue, 26 Feb 2008 22:03:24 -0800 writes:
   
{with many superfluous empty statements ( i.e., trailing ; ):
 
   Indeed!
 
 I like to add a personal touch to the code I'm writing ;)
 
 Seriously, I added them here as a bait in order to get a chance to say
 that I finally found a good reason for adding the semicolons.  If you
 cut'n'paste code from certain web pages it may happen that
 newlines/carriage returns are not transferred and all code is pasted
 into the same line at the R prompt.  With semicolons you still get a
 valid syntax.  I cannot remember under what conditions this happened -
 
 I have seen that too and many others have as well since in some forums
 (not related to R) its common to indent all source lines by two spaces.
 Any line appearing without indentation must have been wrapped.

TH A not-so-subtle solution to this (subtle or not) problem.

:-)

TH NEVER paste from a browser (or a Word doc, or anything similar)
TH into the R command interface. Paste only from pure plain text.

Yes.  Thank you, Ted, for your good points which I'm just
re-iterating in the following:

TH Therefore, if you must paste, then paste first into a window
TH where a pure-plain-text editor is running.

Yes; or an R-aware editor (Tinn-R, Emacs(ESS), WinEDT, )

TH Then you can see what you're getting, and can clean it up.

Yes; this gets you an ``R script file'' (ending that in '.R' is
a good choice) that you also can comment further etc etc

TH After that, you can paste from this directly into R, or can
TH save the file and source() it.

TH Ted.
Yes, or (better :-) once you're using an R-aware editor, you can
send parts or all of the file to the running R also more quickly.


Using R code in *files* that you save, comment, re-evaluate, ...
IMO is still *the* way to do (almost) anything serious with R.

Using extraneous ; at the end of lines, just to allow
something which is not at all recommendable
is not a good reason IMO.
Martin

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


[Rd] ifelse drops classes

2008-02-29 Thread Hilmar Berger
Hi all,

I guess that this is rather a feature request than a bug report, but I'm 
not really sure:

I stumbled over this today (R 2.6.2, WinXP):

  c=c(as.Date(2007-01-01))
  class(c)
[1] Date
  ifelse(is.na(c),as.Date(Sys.time()), c)
[1] 13514
  typeof(ifelse(is.na(c),as.Date(Sys.time()), c))
[1] double
  class(ifelse(is.na(c),as.Date(Sys.time()), c))
[1] numeric
  mode(ifelse(is.na(c),as.Date(Sys.time()), c))
[1] numeric

So - unexpected by me - ifelse drops the date class.

Afterwards I found in the Help page:

The mode of the result may depend on the value of test, and the class 
attribute of the result is taken from test and may be inappropriate for 
the values selected from yes and no.

So even I should expect that the class of the results might not Date,

1. shouldn't it be 'logical' (class(TRUE)) instead of 'numeric' ?
2. Isn't it pretty useless to take the class from the test argument, 
given the fact that this will be usely class(TRUE/FALSE) ?
3. If we can take the mode from the value selected, why can't we take 
the class attribute as well ?

The Help page advices:
Sometimes it is better to use a construction such as (tmp - yes; 
tmp[!test] - no[!test]; tmp), possibly extended to handle missing 
values in test.

So - why doesn't ifelse use a similiar construction ?

In conclusion, I plead for changing ifelse() to not drop class attributes.

Regards,
Hilmar

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


[Rd] patch for random.c

2008-02-29 Thread Berwin A Turlach
Dear all,

while looking for some inspiration of how to organise some code, I
studied the code of random.c and noticed that for distributions with
2 or 3 parameters the user is not warned if NAs are created while such
a warning is issued for distributions with 1 parameter.  E.g:

R version 2.7.0 Under development (unstable) (2008-02-29 r44639)

[...]

 rexp(2, rate=Inf)
[1] NaN NaN
Warning message:
In rexp(2, rate = Inf) : NAs produced
 rnorm(2, mean=Inf)
[1] NaN NaN

Surprisingly, the code for issuing warnings for distributions with 2 or
3 parameters is essentially there, but does not seem to be used.  The
attached patch rectifies this.  With the patch the above command produce
the following output:

 rexp(2, rate=Inf)
[1] NaN NaN
Warning message:
In rexp(2, rate = Inf) : NAs produced
 rnorm(2, mean=Inf)
[1] NaN NaN
Warning message:
In rnorm(2, mean = Inf) : NAs produced

Please ignore the patch if the code that was designed to produce the
warning had been removed on purpose.  

BTW, there are other places in the code were NAs can be created but no
warning is issued.  E.g:

 rexp(2, rate=numeric())
[1] NA NA
 rnorm(2, mean=numeric())
[1] NA NA

I wonder whether a warning should be issued in this case too.  

Best wishes,

Berwin

Index: src/main/random.c
===
--- src/main/random.c   (revision 44639)
+++ src/main/random.c   (working copy)
@@ -123,7 +123,7 @@
 
 #define RAND2(num,name) \
case num: \
-   random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
+   naflag = random2(name, REAL(a), na, REAL(b), nb, REAL(x), n); \
break
 
 /* do_random2 - random sampling from 2 parameter families. */
@@ -207,7 +207,7 @@
 
 #define RAND3(num,name) \
case num: \
-   random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, REAL(x), 
n); \
+   naflag = random3(name, REAL(a), na, REAL(b), nb, REAL(c), nc, 
REAL(x), n); \
break
 
 
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Can't interrupt R-processes in R OSX 2.6.2

2008-02-29 Thread Atte Tenkanen
Hello,

Before I was able to interrupt R-calculations by pushing ESC, but now with R 
2.6.2 (OSX Intel) it doesn't work. Is it bug or not? 

Regards,

Atte Tenkanen
University of Turku, Finland
Department of Musicology
+023335278

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


Re: [Rd] Can't interrupt R-processes in R OSX 2.6.2

2008-02-29 Thread Prof Brian Ripley
On Fri, 29 Feb 2008, Atte Tenkanen wrote:

 Hello,

 Before I was able to interrupt R-calculations by pushing ESC, but now 
 with R 2.6.2 (OSX Intel) it doesn't work. Is it bug or not?

You mean from the R.app GUI?  This has been discussed on the R-sig-mac 
list (the appropriate place for this question), and the advice is to 
update your version of R.app. But please consult the list archives at 
https://stat.ethz.ch/pipermail/r-sig-mac/.


 Regards,

 Atte Tenkanen
 University of Turku, Finland
 Department of Musicology
 +023335278

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


-- 
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