[Rd] calling handlers within R_tryEval

2009-06-16 Thread Romain Francois


Hello,

When using R_tryEval (from JRI in my case), is there a way to setup 
error recovery strategy and more generally calling handlers.
From my reading of context.c, R_tryEval calls R_ToplevelExec which 
creates a context like this:


   begincontext(&thiscontext, CTXT_TOPLEVEL, R_NilValue, R_GlobalEnv,
R_BaseEnv, R_NilValue, R_NilValue);

so I guess what I am trying to do is add "cend" and/or "handlerstack" to 
this context. Is this possible ? Are there examples of packages doing this ?


Romain

--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

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


Re: [Rd] Masked user input - SOLVED

2009-06-16 Thread miller_2555



> ...
> (This is modified from an example on James Wettenhall's page 
> http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/).
> 
> Duncan Murdoch
> 

I had not considered a GUI solution. This works perfectly! Many thanks for
the help. If I come across a CLI solution, I will post here in case others
find it useful (i.e. in case R is running at a low runlevel for *NIX
environments). Thanks again. 
-- 
View this message in context: 
http://www.nabble.com/Masked-user-input-tp24005544p24038191.html
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


Re: [Rd] R build fails during make when configured with "--with-x=no" (PR#13665)

2009-06-16 Thread kevmac

I still have that same error.


Simon Urbanek wrote:
> 
> It should be fixed now.
> 
> Cheers,
> Simon
> 
> On Apr 20, 2009, at 6:58 AM, Peter Dalgaard wrote:
> 
>> j...@ku.edu wrote:
>>
>>>
>>> If R is configured using the "--with=x=no" option, then the make  
>>> fails with the
>>> following error:
>> 
>>> make[1]: *** [R] Error 1
>>> make[1]: Leaving directory `/home/jeet/Scratch/r-build/on-frontend/ 
>>> R-2.9.0/src'
>>> make: *** [R] Error 1
>>>
>>> The problem appears to be with the "src/modules/Makefile".  
>>> Specfically, lines
>>> 26-29:
>>>
>>> @for d in "$(R_MODULES)"; do \
>>>   (cd $${d} && $(MAKE) $@) || exit 1; \
>>> done
>>>
>>> Here, R_MODULES is blank, resulting in the "cd" command  
>>> transferring to the
>>> user's home directory, where, of course, no Makefile is found  
>>> resulting in the
>>> error above.
>>
>> (Even more "fun" would ensue if in fact there were a Makefile  
>> there...)
>>
>>
>>> Work-around appears to be to simply disable loop if R_MODULES is  
>>> empty.
>>
>> Shell script and Make portability is a pain in the derriere, but
>> offhand, those double quotes just look wrong:
>>
>> viggo:~/>for i in "" ; do echo $i; done
>>
>> viggo:~/>for i in  ; do echo $i; done
>> viggo:~/>for i in "foo bar" ; do echo $i; done
>> foo bar
>> viggo:~/>for i in foo bar ; do echo $i; done
>> foo
>> bar
>>
>> Notice that the versions with quotes invariably do the Wrong Thing
>>
>>
>> -- 
>>   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
>> ~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45)  
>> 35327907
>>
>> __
>> 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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/R-build-fails-during-make-when-configured-with-%22--with-x%3Dno%22-%28PR-13665%29-tp23133399p24024281.html
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] Wishlist: as.raw [or similar] support for tcl strings (PR#13758)

2009-06-16 Thread whorfin
Full_Name: Rick Sayre
Version: 2.9.0
OS: windows, os x, linux
Submission from: (NULL) (138.72.153.236)


if a tcl "string" contains binary data, there is a problem getting this data
to R, since there appears to be no way to get "raw" data without NULL
interpretation.  Here is a simple example.  The data should be
Here are 1Here is 2And finally three
> tq <- .Tcl("set tcls [binary format H*
\"4865726520617265203100486572652069732032416E642066696E616C6C7920746872656500\"]")
#tclvalue stops returning data after the first NULL
> tclvalue("tcls")
[1] "Here are 1"
#interestingly, as.character gets more, but gets confused
> as.character(tq)
[1] "Here""are" "1"   "is"  "2"   "finally" "three"
> # we confirm that the tcl representation does indeed have the NULLs:
> .Tcl("binary scan $tcls H* tmps")
 1
> tclvalue("tmps")
[1] 
"4865726520617265203100486572652069732032416e642066696e616c6c7920746872656500"

I would naively suggest something like tclrawvalue() and/or as.raw() utilizing
Tcl_GetByteArrayFromObj

A good discussion of the basics of this issue for general tcl embedding can be
found here:
http://www2.tcl.tk/1180

For those who might be wondering "what the heck are you doing trying to pass
binary data from tcl?", the answer is that non-blocking I/O does not work on
windows,
and timeouts, modes, and line control for RS232 ports aren't supported at all on
R.
Using tcl provides a nice portable way to do this in R, but currently requires
converting everything to ascii encodings since the binary data fails to make it
across.

Cheers
   --Rick

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


Re: [Rd] R build fails during make when configured with "--with-x=no" (PR#13665)

2009-06-16 Thread Simon Urbanek


On Jun 14, 2009, at 14:16 , kevmac wrote:



I still have that same error.



Can you be more specific, please (exact errors, config.log, R  
version ...)? Are you using latest R?


Cheers,
Simon


Do you have the la



Simon Urbanek wrote:


It should be fixed now.

Cheers,
Simon

On Apr 20, 2009, at 6:58 AM, Peter Dalgaard wrote:


j...@ku.edu wrote:



If R is configured using the "--with=x=no" option, then the make
fails with the
following error:



make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/jeet/Scratch/r-build/on-frontend/
R-2.9.0/src'
make: *** [R] Error 1

The problem appears to be with the "src/modules/Makefile".
Specfically, lines
26-29:

@for d in "$(R_MODULES)"; do \
  (cd $${d} && $(MAKE) $@) || exit 1; \
done

Here, R_MODULES is blank, resulting in the "cd" command
transferring to the
user's home directory, where, of course, no Makefile is found
resulting in the
error above.


(Even more "fun" would ensue if in fact there were a Makefile
there...)



Work-around appears to be to simply disable loop if R_MODULES is
empty.


Shell script and Make portability is a pain in the derriere, but
offhand, those double quotes just look wrong:

viggo:~/>for i in "" ; do echo $i; done

viggo:~/>for i in  ; do echo $i; done
viggo:~/>for i in "foo bar" ; do echo $i; done
foo bar
viggo:~/>for i in foo bar ; do echo $i; done
foo
bar

Notice that the versions with quotes invariably do the Wrong  
Thing



--
 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
~~ - (p.dalga...@biostat.ku.dk)  FAX: (+45)
35327907

__
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




--
View this message in context: 
http://www.nabble.com/R-build-fails-during-make-when-configured-with-%22--with-x%3Dno%22-%28PR-13665%29-tp23133399p24024281.html
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


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


[Rd] Dynamic Library linked with Parallel Intel MKL

2009-06-16 Thread Markus Jochmann

Hi!

I call some external C++ code from R using dyn.load() and .C(). My dynamic
library is linked to the parallel Intel MKL libraries and thus should make
use of my quadcore processor. In fact, it does if I call it from a C++
program but not if I call it from R 2.8.1 packaged by Ubuntu (there it only
uses one core).

Is there some trick? Do I need to link the whole of R with parallel MKL?

Thanks a lot,
Markus.
-- 
View this message in context: 
http://www.nabble.com/Dynamic-Library-linked-with-Parallel-Intel-MKL-tp24053462p24053462.html
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


Re: [Rd] calling handlers within R_tryEval

2009-06-16 Thread luke

Not at present.  It would be nice to have at least a mechanism for C
level exiting handlers (which is what the cend ones are intended to be)
but it hasn't risen high enough on my to do list yet to get done.

luke

On Tue, 16 Jun 2009, Romain Francois wrote:



Hello,

When using R_tryEval (from JRI in my case), is there a way to setup error 
recovery strategy and more generally calling handlers.
From my reading of context.c, R_tryEval calls R_ToplevelExec which creates a 
context like this:


  begincontext(&thiscontext, CTXT_TOPLEVEL, R_NilValue, R_GlobalEnv,
   R_BaseEnv, R_NilValue, R_NilValue);

so I guess what I am trying to do is add "cend" and/or "handlerstack" to this 
context. Is this possible ? Are there examples of packages doing this ?


Romain




--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  l...@stat.uiowa.edu
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu

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


Re: [Rd] read.csv

2009-06-16 Thread Petr Savicky
On Sun, Jun 14, 2009 at 09:21:24PM +0100, Ted Harding wrote:
> On 14-Jun-09 18:56:01, Gabor Grothendieck wrote:
> > If read.csv's colClasses= argument is NOT used then read.csv accepts
> > double quoted numerics:
> > 
> > 1: > read.csv(stdin())
> > 0: A,B
> > 1: "1",1
> > 2: "2",2
> > 3:
> >   A B
> > 1 1 1
> > 2 2 2
> > 
> > However, if colClasses is used then it seems that it does not:
> > 
> >> read.csv(stdin(), colClasses = "numeric")
> > 0: A,B
> > 1: "1",1
> > 2: "2",2
> > 3:
> > Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
> > na.strings,  :
> >   scan() expected 'a real', got '"1"'
> > 
> > Is this really intended?  I would have expected that a csv file
> > in which each field is surrounded with double quotes is acceptable
> > in both cases. This may be documented as is yet seems undesirable
> > from both a consistency viewpoint and the viewpoint that it should
> > be possible to double quote fields in a csv file.
> 
> Well, the default for colClasses is NA, for which ?read.csv says:
>   [...]
>   Possible values are 'NA' (when 'type.convert' is used),
>   [...]
> and then ?type.convert says:
>   This is principally a helper function for 'read.table'. Given a
>   character vector, it attempts to convert it to logical, integer,
>   numeric or complex, and failing that converts it to factor unless
>   'as.is = TRUE'.  The first type that can accept all the non-missing
>   values is chosen.
> 
> It would seem that type 'logical' won't accept integer (naively one
> might expect 1 --> TRUE, but see experiment below), so the first
> acceptable type for "1" is integer, and that is what happens.
> So it is indeed documented (in the R[ecursive] sense of "documented" :))
> 
> However, presumably when colClasses is used then type.convert() is
> not called, in which case R sees itself being asked to assign a
> character entity to a destination which it has been told shall be
> integer, and therefore, since the default for as.is is
>   as.is = !stringsAsFactors
> but for this ?read.csv says that stringsAsFactors "is overridden
> bu [sic] 'as.is' and 'colClasses', both of which allow finer
> control.", so that wouldn't come to the rescue either.
> 
> Experiment:
>   X <-logical(10)
>   class(X)
>   # [1] "logical"
>   X[1]<-1
>   X
>   # [1] 1 0 0 0 0 0 0 0 0 0
>   class(X)
>   # [1] "numeric"
> so R has converted X from class 'logical' to class 'numeric'
> on being asked to assign a number to a logical; but in this
> case its hands were not tied by colClasses.
> 
> Or am I missing something?!!

In my opinion, you explain, how it happens that there is a difference
in the behavior between
  read.csv(stdin(), colClasses = "numeric")
and
  read.csv(stdin())
but not, why it is so.

The algorithm "use the smallest type, which accepts all non-missing values"
may well be applied to the input values either literally or after removing
the quotes. Is there a reason, why
  read.csv(stdin(), colClasses = "numeric")
removes quotes from the input values and
  read.csv(stdin())
does not?

Using double-quote characters is a part of the definition of CSV file, see,
for example
  http://en.wikipedia.org/wiki/Comma_separated_values
where one may find
  Fields may always be enclosed within double-quote characters, whether 
necessary or not.

Petr.

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


Re: [Rd] calling handlers within R_tryEval

2009-06-16 Thread Romain Francois

Hi,

If there is something I can do to push up this one, let me know.

Romain

l...@stat.uiowa.edu wrote:


Not at present.  It would be nice to have at least a mechanism for C
level exiting handlers (which is what the cend ones are intended to be)
but it hasn't risen high enough on my to do list yet to get done.

luke

On Tue, 16 Jun 2009, Romain Francois wrote:



Hello,

When using R_tryEval (from JRI in my case), is there a way to setup 
error recovery strategy and more generally calling handlers.
From my reading of context.c, R_tryEval calls R_ToplevelExec which 
creates a context like this:


  begincontext(&thiscontext, CTXT_TOPLEVEL, R_NilValue, R_GlobalEnv,
   R_BaseEnv, R_NilValue, R_NilValue);

so I guess what I am trying to do is add "cend" and/or "handlerstack" 
to this context. Is this possible ? Are there examples of packages 
doing this ?


Romain




--
Romain Francois
Independent R Consultant
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr

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