Re: [Rd] interfacing R with RFC2445

2010-01-14 Thread Barry Rowlingson
On Mon, Jan 11, 2010 at 10:10 PM, Jeff Hamann jeff.d.ham...@gmail.comwrote:

 R Developers,

 I cannot seem to find an R package that can read/write iCalendar (RFC2445)
 files.

 I have found the libical library at sourceforge. I've used it briefly so it
 may be what I need, but again no R interface. I may have to connect the dots
 myself.

 I'm guessing this might be useful for someone other than myself (scrubbing
 files, performing temporal analysis on events, etc).

 Since I need to perform these tasks, I will probably do it using R if I can
 get away with it.

 Can anyone provide some basic advice for me? A list object of entries? The
 original data will be coming from an SQL table/view result.

 Is there any interest in helping with funding such a small project?


 Small project? The python icalendar package is about 3000 lines of code,
plus tests.

 ical is quite a complex format with all sorts of functionalities. The
chances are that if your ical files come from a simple source and don't use
all the complications of ical format then you can write an ad-hoc parser
that just strips out the event time (or whatever) you need.

 If you still *do* want to write a full iCalendar reader/parser, the python
package might be a good place to start and look for ideas.

Barry

-- 
blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

[[alternative HTML version deleted]]

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


[Rd] how to call a function from C

2010-01-14 Thread Romain Francois

Hi,

In Rcpp, we now have a Function class to encapsulate functions (they 
cover all three kinds, but this may change).


To call the function, what we do is generate a call with the function as 
the first node and then evaluate the call.


SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) );
SEXP rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ;
SEXP call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10), 
CONS(ScalarReal(0), R_NilValue ) ) ) );

SEXP res = PROTECT( eval( call , R_GlobalEnv ) );
UNPROTECT(4) ;
return res ;

It works, but I was wondering if there was another way. I've seen 
applyClosure, but I'm not sure I should attempt to use it or if using a 
call like above is good enough.


Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ;
Function rnorm = stats.get( rnorm )
return rnorm( 10, 0.0 ) ;


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

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


Re: [Rd] how to call a function from C

2010-01-14 Thread Laurent Gautier



Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as 
one function-like class and seems to be behave reasonably while a lot of 
other things seem more urgent to sort out.



To call the function, what we do is generate a call with the function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've seen
applyClosure, but I'm not sure I should attempt to use it or if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given 
environment, as well as capture an eventual error occurring during its 
evaluation (and translate it as an exception).



Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for 
do_try_eval. The behavior looks very similar, the above snippet in 
rpy2 would write like:


from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)



-- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr |- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp `-
http://tr.im/JFqa : R Journal, Volume 1/2, December 2009


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


Re: [Rd] wiki down?

2010-01-14 Thread Matthew Dowle
I see the same problem. The wiki link on the R homepage doesn't seem to 
respond.
A search of r-devel for subjects containing wiki finds this seemingly 
unanswered recent post.
Is it known?
-Matthew

Ben Bolker bol...@ufl.edu wrote in message 
news:4b44b12a.60...@ufl.edu...


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


Re: [Rd] how to call a function from C

2010-01-14 Thread Romain Francois

On 01/14/2010 12:42 PM, Laurent Gautier wrote:

Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as
one function-like class and seems to be behave reasonably while a lot of
other things seem more urgent to sort out.


To call the function, what we do is generate a call with the function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've seen
applyClosure, but I'm not sure I should attempt to use it or if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given
environment, as well as capture an eventual error occurring during its
evaluation (and translate it as an exception).


Sure. I did not want to over-complicate the question.

I'm currently reviewing tryEval and its underlying R_TopLevelExec which 
does not give me enough : when the error occurs, it'd be useful that the 
function returns the condition object instead of NULL.



Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for
do_try_eval. The behavior looks very similar, the above snippet in
rpy2 would write like:

from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)


nice

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

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


Re: [Rd] how to call a function from C

2010-01-14 Thread Laurent Gautier

On 1/14/10 1:16 PM, Romain Francois wrote:

On 01/14/2010 12:42 PM, Laurent Gautier wrote:

Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as
one function-like class and seems to be behave reasonably while a lot of
other things seem more urgent to sort out.


To call the function, what we do is generate a call with the function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've seen
applyClosure, but I'm not sure I should attempt to use it or if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given
environment, as well as capture an eventual error occurring during its
evaluation (and translate it as an exception).


Sure. I did not want to over-complicate the question.

I'm currently reviewing tryEval and its underlying R_TopLevelExec which
does not give me enough : when the error occurs, it'd be useful that the
function returns the condition object instead of NULL.


I possibly went the same path, and ended with R_tryEval. When looking at 
it, I could not figure out any way to get what I wanted outside using 
geterrmessage in base.
The error string is in the variable errbuf (in src/main/error.c), with 
no obvious route to access it (and if truly no route, this might be 
something missing from the R C-API).



Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for
do_try_eval. The behavior looks very similar, the above snippet in
rpy2 would write like:p/


I meant do_eval_expr.



from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)


nice



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


Re: [Rd] how to call a function from C

2010-01-14 Thread Dominick Samperi
The Rcpp library in RcppTemplate (the package that Rcpp forked from)
simplifies the process
of calling functions from C++. The design goal was to enable users to focus
on
scientific problem solving rather than interface problems and low-level R
internals (by
hiding these details and documenting everything).

The current Rcpp package is a mashup of the packages RcppTemplate (old
version),
inline, and RInside that involves a fair amount of low-level R hacking, and
this is
probably consistent with the preferences of most readers of this list.

If I am mistaken and there are any users of RcppTemplate please let me know,
as I
am thinking about reoganizing that package to minimize confusion with the
fork.

Thanks,
Dominick

On Thu, Jan 14, 2010 at 7:16 AM, Romain Francois romain.franc...@dbmail.com
 wrote:

 On 01/14/2010 12:42 PM, Laurent Gautier wrote:

 Hi,

 In Rcpp, we now have a Function class to encapsulate functions
 (they cover all three kinds, but this may change).


 Just a note on that: there is probably no hurry to do so.
 rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as
 one function-like class and seems to be behave reasonably while a lot of
 other things seem more urgent to sort out.

  To call the function, what we do is generate a call with the function
 as the first node and then evaluate the call.

 SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
 rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
 call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
 CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
 call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

 It works, but I was wondering if there was another way. I've seen
 applyClosure, but I'm not sure I should attempt to use it or if using
 a call like above is good enough.


 Using R_tryEval() will let you evaluate an expression in a given
 environment, as well as capture an eventual error occurring during its
 evaluation (and translate it as an exception).


 Sure. I did not want to over-complicate the question.

 I'm currently reviewing tryEval and its underlying R_TopLevelExec which
 does not give me enough : when the error occurs, it'd be useful that the
 function returns the condition object instead of NULL.


  Romain

 PS: using Rcpp's C++ classes you would express the code above as :

 Environment stats(package:stats) ; Function rnorm = stats.get(
 rnorm ) return rnorm( 10, 0.0 ) ;


 Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for
 do_try_eval. The behavior looks very similar, the above snippet in
 rpy2 would write like:

 from rpy2.robjects.packages import importr
 stats = importr('stats')
 stats.rnorm(10, 0.0)


 nice


 --
 Romain Francois
 Professional R Enthusiast
 +33(0) 6 28 91 30 30
 http://romainfrancois.blog.free.fr
 |- http://tr.im/KfKn : Rcpp 0.7.2
 |- http://tr.im/JOlc : External pointers with Rcpp
 `- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

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


[[alternative HTML version deleted]]

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


Re: [Rd] how to call a function from C

2010-01-14 Thread Romain Francois

On 01/14/2010 03:50 PM, Dominick Samperi wrote:

The Rcpp library in RcppTemplate (the package that Rcpp forked from)
simplifies the process
of calling functions from C++. The design goal was to enable users to
focus on
scientific problem solving rather than interface problems and low-level
R internals (by
hiding these details and documenting everything).


Hello Dominick,

In the Rcpp package, you'd call the rnorm function like this :

/* grab the environment called package:stats */
Environment stats(package:stats) ;
/* or like this if you want the namespace */
/* Environment stats = Environment::namespace_env(stats) ;*/

/* grab function called 'rnorm' from this environment */
Function rnorm = stats.get(rnorm ) ;

/* call the function, about the same way you'd do in R
 *
 *  rnorm( 10L, sd = 100 )
 */
return rnorm( 10, Named( sd, 100.0 ) ) ;

All involved SEXP are encapsulated in suitable C++ objects, such as 
Environment, Function, etc ... the user does not need to know about 
SEXP, does not need to care about the PROTECT/UNPROTECT dance, etc ...


Please let me know which of these three lines of C++ code you consider 
to be low level R internals.


It might be interesting that you post how you would invoke the same 
using RcppTemplate.



The current Rcpp package is a mashup of the packages RcppTemplate (old
version),
inline, and RInside


It is not anything even kind of close to that.

There was code from the inline package at some point, but it is now back 
into inline, which has been improved to support easy inlining of code 
making use of Rcpp.


There is nothing of RInside in Rcpp, it goes the other way, RInside 
depends on Rcpp and uses its features to ease embedding R into an 
existing C++ application


The Rcpp package is under a lot of changes. See :
- http://dirk.eddelbuettel.com/blog/2010/01/12/#rcpp_0.7.2
- http://dirk.eddelbuettel.com/blog/2010/01/02/#rcpp_0.7.1
- 
http://romainfrancois.blog.free.fr/index.php?post/2010/01/13/Rcpp-0.7.2-is-out
- 
http://romainfrancois.blog.free.fr/index.php?post/2010/01/08/External-pointers-with-Rcpp
- 
http://romainfrancois.blog.free.fr/index.php?post/2009/12/29/new-things-in-Rcpp



that involves a fair amount of low-level R hacking,
and this is
probably consistent with the preferences of most readers of this list.


Can you be more specific ?

The whole purpose of the package is to hide the R API. The user does not 
need to know the R API to use the classes of Rcpp. We however indeed use 
and abuse the R API a lot internally.


Romain


If I am mistaken and there are any users of RcppTemplate please let me
know, as I
am thinking about reoganizing that package to minimize confusion with
the fork.

Thanks,
Dominick

On Thu, Jan 14, 2010 at 7:16 AM, Romain Francois
romain.franc...@dbmail.com mailto:romain.franc...@dbmail.com wrote:

On 01/14/2010 12:42 PM, Laurent Gautier wrote:

Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP
represented as
one function-like class and seems to be behave reasonably while
a lot of
other things seem more urgent to sort out.

To call the function, what we do is generate a call with the
function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) )
); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) )
) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT(
eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've
seen
applyClosure, but I'm not sure I should attempt to use it or
if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given
environment, as well as capture an eventual error occurring
during its
evaluation (and translate it as an exception).


Sure. I did not want to over-complicate the question.

I'm currently reviewing tryEval and its underlying R_TopLevelExec
which does not give me enough : when the error occurs, it'd be
useful that the function returns the condition object instead of NULL.


Romain

PS: using Rcpp's C++ classes you would express the code
above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and
look for
do_try_eval. The behavior looks very similar, the above 

Re: [Rd] how to call a function from C

2010-01-14 Thread Dominick Samperi
On Thu, Jan 14, 2010 at 10:20 AM, Romain Francois 
romain.franc...@dbmail.com wrote:

 It might be interesting that you post how you would invoke the same using
 RcppTemplate.

Sorry, I will not complete with my own work.

The point of my last post was to see if anybody still uses RcppTemplate so I
can
decide what to do with that package.

[[alternative HTML version deleted]]

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


Re: [Rd] how to call a function from C

2010-01-14 Thread Romain Francois

On 01/14/2010 02:27 PM, Laurent Gautier wrote:


On 1/14/10 1:16 PM, Romain Francois wrote:

On 01/14/2010 12:42 PM, Laurent Gautier wrote:

Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as
one function-like class and seems to be behave reasonably while a lot of
other things seem more urgent to sort out.


To call the function, what we do is generate a call with the function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've seen
applyClosure, but I'm not sure I should attempt to use it or if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given
environment, as well as capture an eventual error occurring during its
evaluation (and translate it as an exception).


Sure. I did not want to over-complicate the question.

I'm currently reviewing tryEval and its underlying R_TopLevelExec which
does not give me enough : when the error occurs, it'd be useful that the
function returns the condition object instead of NULL.


I possibly went the same path, and ended with R_tryEval. When looking at
it, I could not figure out any way to get what I wanted outside using
geterrmessage in base.
The error string is in the variable errbuf (in src/main/error.c), with
no obvious route to access it (and if truly no route, this might be
something missing from the R C-API).


It seems to be the regular way around this gap. Martin Morgan gave the 
same advice (using geterrmessage) here last week. it only gives you the 
error message though


I've been staring at R_ToplevelExec, begincontext and addCondHands. Some 
day, I'll understand how to connect the dots. Not today though.


Romain


Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for
do_try_eval. The behavior looks very similar, the above snippet in
rpy2 would write like:p/


I meant do_eval_expr.


thanks.


from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)


nice



--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/KfKn : Rcpp 0.7.2
|- http://tr.im/JOlc : External pointers with Rcpp
`- http://tr.im/JFqa : R Journal, Volume 1/2, December 2009

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


Re: [Rd] wiki down?

2010-01-14 Thread Friedrich Leisch
 On Thu, 14 Jan 2010 11:45:31 -,
 Matthew Dowle (MD) wrote:

   I see the same problem. The wiki link on the R homepage doesn't seem to 
   respond.
   A search of r-devel for subjects containing wiki finds this seemingly 
   unanswered recent post.
   Is it known?


Philippe Grosjean maintains the Wiki, in CC.

Best,
Fritz

-- 
---
Prof. Dr. Friedrich Leisch 

Institut für Statistik  Tel: (+49 89) 2180 3165
Ludwig-Maximilians-Universität  Fax: (+49 89) 2180 5308
Ludwigstraße 33
D-80539 München http://www.statistik.lmu.de/~leisch
---
   Journal Computational Statistics --- http://www.springer.com/180 
  Münchner R Kurse --- http://www.statistik.lmu.de/R

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


Re: [Rd] how to call a function from C

2010-01-14 Thread luke

On Thu, 14 Jan 2010, Romain Francois wrote:


On 01/14/2010 12:42 PM, Laurent Gautier wrote:

Hi,

In Rcpp, we now have a Function class to encapsulate functions
(they cover all three kinds, but this may change).


Just a note on that: there is probably no hurry to do so.
rpy2 is also having CLOSXP, BUILTINSXP, and SPECIALSXP represented as
one function-like class and seems to be behave reasonably while a lot of
other things seem more urgent to sort out.


To call the function, what we do is generate a call with the function
as the first node and then evaluate the call.

SEXP stats = PROTECT( R_FindNamespace( mkString( stats) ) ); SEXP
rnorm = PROTECT( findVarInFrame( stats, install( rnorm) ) ) ; SEXP
call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10),
CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval(
call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ;

It works, but I was wondering if there was another way. I've seen
applyClosure, but I'm not sure I should attempt to use it or if using
a call like above is good enough.


Using R_tryEval() will let you evaluate an expression in a given
environment, as well as capture an eventual error occurring during its
evaluation (and translate it as an exception).


Sure. I did not want to over-complicate the question.

I'm currently reviewing tryEval and its underlying R_TopLevelExec which does 
not give me enough : when the error occurs, it'd be useful that the function 
returns the condition object instead of NULL.


R_TopLevelExec, and hence R_tryEval, don't quite do what some users
expect and maybe would like. There are two issues.

The TopLevel part means that conceptually this call runs in its own
stack, which means things like calling error handlers set up outside
this call are not visible, and Sys.whatever functions don't see the
rest of the stack (or at least should not). A call to one of these is
conceptually a bit like asking a separate thread to evaluate the
expression and waiting for the result.  (I believe his mechanism was
added to handle finalizer code in the GC, where this makes sense, but
I may have my history wrong.)

The other issue is that what R_tryEval catches is not errors, it is
longjmp attempts.  The vast majority of these will come from attempts
to pass errors to exiting handlers, but there are other possibilities,
such as invoking an abort restart (which jumps to top level).

It might be useful to provide a C level interface for catching errors
as well as other jumps and for allowing C code to do cleanup
operations and then continue those jumps if appropriate, but getting
that right is fairly tricky and certainly hasn't risen high enough on
my priority list to warrant the investment of time.  The interface
would have to abstract over implementation details though: we
definitely do not want to expose and commit to current details of the
context stack implementation.

luke





Romain

PS: using Rcpp's C++ classes you would express the code above as :

Environment stats(package:stats) ; Function rnorm = stats.get(
rnorm ) return rnorm( 10, 0.0 ) ;


Feel free to snoop in rpy2's rpy/rinterface/rinterface.c and look for
do_try_eval. The behavior looks very similar, the above snippet in
rpy2 would write like:

from rpy2.robjects.packages import importr
stats = importr('stats')
stats.rnorm(10, 0.0)


nice




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


[Rd] RcppTemplate user alert

2010-01-14 Thread Dominick Samperi
If there are any users of RcppTemplate package Version 6+ please
let me know ASAP as I will probably reorganize this package to
limit confusion and overlap with the package Rcpp.

Since the package Rcpp which forked from an earlier version of RcppTemplate
seems
to have the support of many people in the R community it is
counterproductive
for me to continue work on RcppTemplate in its current form.

Thanks,
Dominick

[[alternative HTML version deleted]]

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


[Rd] Wishlist: system.file(... package) throw an error if package not installed/path not found

2010-01-14 Thread Henrik Bengtsson
Currently, system.file() on a non-existing package returns an empty string:

path - system.file(package=foo);
print(path);
[1] 

The same goes for non-existing paths in existing package directories:

path - system.file(foo, package=base);
print(path);
[1] 

Is there a rationale for this, or is it just for historical reasons?
Is the empty string  used in R to represent a missing file?  (e.g.
file.exists() == FALSE).

I would like to suggest that an error is thrown instead, so that it is
caught as soon as possible and not down stream.

/Henrik

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


Re: [Rd] Wishlist: system.file(... package) throw an error if package not installed/path not found

2010-01-14 Thread Simon Urbanek


On Jan 14, 2010, at 15:01 , Henrik Bengtsson wrote:

Currently, system.file() on a non-existing package returns an empty  
string:


path - system.file(package=foo);
print(path);
[1] 

The same goes for non-existing paths in existing package directories:

path - system.file(foo, package=base);
print(path);
[1] 

Is there a rationale for this, or is it just for historical reasons?
Is the empty string  used in R to represent a missing file?  (e.g.
file.exists() == FALSE).

I would like to suggest that an error is thrown instead, so that it is
caught as soon as possible and not down stream.



I cannot answer for the original author, but throwing an error is  
generally a very bad idea since it defeats the vectorization. It is  
much easier to simply use if(nzchar(system.file(...))) if you want to  
throw an error in a scalar context than to lose all results because of  
one vector entry. And, yes, file.exists() will indeed return FALSE  
(although it is entirely unrelated).


Cheers,
Simon

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


[Rd] adapt package missing because of licensing issue: fix?

2010-01-14 Thread Ben Bolker

  I think this is probably known by someone, but I wanted to ask/comment:

  The 'adapt' package has been removed from CRAN because of an 'unclear'
license. That makes sense, but it actually took a bit of digging for me
to discover that, and if I had been a student I might not have figured
it out.  The package is simply missing from the CRAN compiled packages
page; I did find information in the check summaries; but I didn't get a
clear indication until I found

http://cran.r-project.org/web/packages/adapt/index.html

 by googling (which also gave me a handy link to the archives).

https://stat.ethz.ch/pipermail/r-sig-fedora/2009-June/78.html
http://packages.debian.org/changelogs/pool/main/a/adapt/adapt_1.0-4-3/r-cran-adapt.copyright

  give a little more information.

  library(findFn); sos(multidimensional+integration) found the
cubature package for me, which looks like a pretty good replacement but
which I haven't tried out yet.

  My real question: has anyone actually tried to contact the authors and
find out if they are willing to put the code under a suitably
redistributable license? I can't find anything that suggests that they
*don't* want it redistributed ... ? Would it be helpful if I did this,
or is this the sort of thing the package maintainer should do?

Mike Meyer: mi...@andrew.cmu.edu
Alan Genz: g...@gauss.math.wsu.edu

  cheers
Ben Bolker

-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bol...@ufl.edu / people.biology.ufl.edu/bolker
GPG key: people.biology.ufl.edu/bolker/benbolker-publickey.asc



signature.asc
Description: OpenPGP digital signature
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] optional package dependency

2010-01-14 Thread Ross Boylan
I have a package that can use rmpi, but works fine without it.  None of
the automatic test code invokes rmpi functionality.  (One test file
illustrates how to use it, but has quit() as its first command.)

What's the best way to handle this?  In particular, what is the
appropriate form for upload to CRAN?

When I omitted rmpi from the DESCRITPION file R CMD check gave 
quote
* checking R code for possible problems ... NOTE
alldone: no visible global function definition for ‘mpi.bcast.Robj’
alldone: no visible global function definition for ‘mpi.exit’
quote
followed by many more warnings.

When I add
Suggests: Rmpi
in DESCRIPTION the check stops if the package is not installed:
quote
* checking package dependencies ... ERROR
Packages required but not available:
  Rmpi
/quote
Rmpi is not required, but I gather from previous discussion on this list
that suggests basically means required for R CMD check.

NAMESPACE seems to raise similar issues; I don't see any mechanism for
optional imports.  Also, I have not used namespaces, and am not eager to
destabilize things so close to release.  At least, I hope I'm close to
release :)

Thanks for any advice.

Ross Boylan

P.S. Thanks, Duncan, for your recent advice on my help format problem
with R 2.7.  I removed the nested \description, and now things look OK.

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


Re: [Rd] optional package dependency

2010-01-14 Thread Jeff Ryan
Hi Ross,

The quantmod package makes available routines from a variety of
contributed packages, but gets around your issues with a bit of, um,
trickery.

Take a look here (unless your name is Kurt ;-) ):

http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/R/buildModel.methods.R?rev=367root=quantmodview=markup

It would be nice to have Suggests really mean suggests to check, but I
am sure there is a good reason it doesn't.

HTH
Jeff

On Fri, Jan 15, 2010 at 12:00 AM, Ross Boylan r...@biostat.ucsf.edu wrote:
 I have a package that can use rmpi, but works fine without it.  None of
 the automatic test code invokes rmpi functionality.  (One test file
 illustrates how to use it, but has quit() as its first command.)

 What's the best way to handle this?  In particular, what is the
 appropriate form for upload to CRAN?

 When I omitted rmpi from the DESCRITPION file R CMD check gave
 quote
 * checking R code for possible problems ... NOTE
 alldone: no visible global function definition for ‘mpi.bcast.Robj’
 alldone: no visible global function definition for ‘mpi.exit’
 quote
 followed by many more warnings.

 When I add
 Suggests: Rmpi
 in DESCRIPTION the check stops if the package is not installed:
 quote
 * checking package dependencies ... ERROR
 Packages required but not available:
  Rmpi
 /quote
 Rmpi is not required, but I gather from previous discussion on this list
 that suggests basically means required for R CMD check.

 NAMESPACE seems to raise similar issues; I don't see any mechanism for
 optional imports.  Also, I have not used namespaces, and am not eager to
 destabilize things so close to release.  At least, I hope I'm close to
 release :)

 Thanks for any advice.

 Ross Boylan

 P.S. Thanks, Duncan, for your recent advice on my help format problem
 with R 2.7.  I removed the nested \description, and now things look OK.

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




-- 
Jeffrey Ryan
jeffrey.r...@insightalgo.com

ia: insight algorithmics
www.insightalgo.com

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


Re: [Rd] optional package dependency

2010-01-14 Thread Jari Oksanen
On Fri, 2010-01-15 at 00:12 -0600, Jeff Ryan wrote:
 Hi Ross,
 
 The quantmod package makes available routines from a variety of
 contributed packages, but gets around your issues with a bit of, um,
 trickery.
 
 Take a look here (unless your name is Kurt ;-) ):
 
 http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/R/buildModel.methods.R?rev=367root=quantmodview=markup
 
 It would be nice to have Suggests really mean suggests to check, but I
 am sure there is a good reason it doesn't.
 
I agree: it would be nice to have Suggests really mean suggests, and
I 'suggested' so in an R-devel message of 20/9/05 with subject Shy
Suggestion (but this seems not exist in the R-devel archive?). I got
some support, but not from the right people, and so the R suggestion
remains the one you can't refuse or you'll wake up with a horse head in
your bed. I can live with this forced suggestion, although it is
sometimes painful, in particular in Mac or after re-installing
everything from scratch in Linux. 

The main argument was that building may fail later if you don't check
suggests early so that you must (de facto) depend on packages you
suggest. I'm sure many packages would fail now if the interpretation of
suggests was changed because the behaviour of suggests and depends
has been near identical for a long time and people have adapted. The
window of opportunity for another interpretation was when the checks for
undefined request() was added to the R CMD check routines in 2005, but
then it was decided that suggests should be near equivalent to
depends, and this will stick.

Cheers, Jari Oksanen

-- 
Jari Oksanen, Department of Biology, Univ Oulu, FI-90014 Oulu, Finland
http://www.oulu.fi/~jarioksa http://vegan.r-forge.r-project.org

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