[Rd] Standalone C++ application for processing R parser output(SEXP)

2011-03-24 Thread Rob Anderson
Hi All,

I am trying to write a source-to-source compiler for R. I am trying to
leverage the R parser code for the purpose. I am trying to transform the
SEXP returned from the parser into an AST for our own Ruby embedded Domain
specific language.

I tried using R CMD SHBIN to compile a C function that parses arbitrary R
expressions. But I think, the generated .so file can be used from within R
and not be called from other C or Ruby programs(I get linker errors).

My Idea  is to use the SEXP processing functions/MACROS (CAR, CDR, CADR,
etc..) from within C code and transform it to our AST format. I tried
linking to libR.a and other lib*.so's when I compile the C code using gcc
but, it doesn't work.

I read that R exposes only small number of functions for library/package
writers and the compiled *.so can only from within R.

Any ideas on what is wrong, or how I can go about it?

Appreciate any help.

Thanks
RJ

[[alternative HTML version deleted]]

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


Re: [Rd] Standalone C++ application for processing R parser output(SEXP)

2011-03-24 Thread Duncan Murdoch

On 11-03-23 7:35 PM, Rob Anderson wrote:

Hi All,

I am trying to write a source-to-source compiler for R. I am trying to
leverage the R parser code for the purpose. I am trying to transform the
SEXP returned from the parser into an AST for our own Ruby embedded Domain
specific language.

I tried using R CMD SHBIN to compile a C function that parses arbitrary R
expressions. But I think, the generated .so file can be used from within R
and not be called from other C or Ruby programs(I get linker errors).

My Idea  is to use the SEXP processing functions/MACROS (CAR, CDR, CADR,
etc..) from within C code and transform it to our AST format. I tried
linking to libR.a and other lib*.so's when I compile the C code using gcc
but, it doesn't work.

I read that R exposes only small number of functions for library/package
writers and the compiled *.so can only from within R.

Any ideas on what is wrong, or how I can go about it?


I think you need to think of your program as a new front end for R, even 
if you're only using a few R functions.  See Chapter 8 in the Writing R 
Extensions manual.


Duncan Murdoch

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


Re: [Rd] Standalone C++ application for processing R parser output(SEXP)

2011-03-24 Thread Dirk Eddelbuettel

On 24 March 2011 at 08:08, Duncan Murdoch wrote:
| On 11-03-23 7:35 PM, Rob Anderson wrote:
|  Hi All,
| 
|  I am trying to write a source-to-source compiler for R. I am trying to
|  leverage the R parser code for the purpose. I am trying to transform the
|  SEXP returned from the parser into an AST for our own Ruby embedded Domain
|  specific language.
| 
|  I tried using R CMD SHBIN to compile a C function that parses arbitrary R
|  expressions. But I think, the generated .so file can be used from within R
|  and not be called from other C or Ruby programs(I get linker errors).
| 
|  My Idea  is to use the SEXP processing functions/MACROS (CAR, CDR, CADR,
|  etc..) from within C code and transform it to our AST format. I tried
|  linking to libR.a and other lib*.so's when I compile the C code using gcc
|  but, it doesn't work.
| 
|  I read that R exposes only small number of functions for library/package
|  writers and the compiled *.so can only from within R.
| 
|  Any ideas on what is wrong, or how I can go about it?
| 
| I think you need to think of your program as a new front end for R, even 
| if you're only using a few R functions.  See Chapter 8 in the Writing R 
| Extensions manual.

Maybe also have a look at the parser package by Romain at

 https://r-forge.r-project.org/R/?group_id=384

(and scroll down sufficiently on that page) which has the description

 parser - Detailed R source code parser   

 detailed source code parser, based on the standard R parser but
 organizing the information differently 

which strikes me as close enough to what you describe. That said, Romain did
this for highlight so it may not be relevant.

Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com

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


[Rd] Orthogonal polynomial ANOVA or polynomial regression?

2011-03-24 Thread Dominick Samperi
Hi,

I have not been able to find R tools that permit an orthogonal polynomial
ANOVA analysis: single degree of freedom F-test comparisons including
L, Q, C, etc. terms. Do such tools exist?

I guess you can accomplish something similar by doing straightforward
polynomial regression and removing powers manually, combined with
ANOVA model comparisons.

Thanks,
Dominick

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


Re: [Rd] Orthogonal polynomial ANOVA or polynomial regression?

2011-03-24 Thread peter dalgaard

On Mar 24, 2011, at 16:53 , Dominick Samperi wrote:

 Hi,
 
 I have not been able to find R tools that permit an orthogonal polynomial
 ANOVA analysis: single degree of freedom F-test comparisons including
 L, Q, C, etc. terms. Do such tools exist?
 
 I guess you can accomplish something similar by doing straightforward
 polynomial regression and removing powers manually, combined with
 ANOVA model comparisons.

(Why R-devel? This is a plain R-help thing.)

Look up contr.poly(), and poly().

Notice that for unbalanced designs, you still need to remove terms one at a 
time.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [Rd] import question

2011-03-24 Thread Ben Bolker
Prof Brian Ripley ripley at stats.ox.ac.uk writes:

 
 On Thu, 24 Mar 2011, Ben Bolker wrote:
 
  Ben Bolker bbolker at gmail.com writes:
 
 
 
I have been struggling all day to import a particular function/method
  combination (ranef(), which extracts the random effects from a mixed
  model fit) from the nlme package into another package ... so far without
  success.
 
 
   Answered my own question, finally.
 
   Apparently an explicit
 
  export(ranef)
 
  is required, even though there is also an
 
  exportPattern(^[^\\.])
 
  in the NAMESPACE file, which I would have thought would
  export 'ranef' along with everything else ... ?
 
 It exports everything excpet dot-namesin the package's namespace. 
 Imports are not in the namespace per se, but in the import environment 
 (which is the enclosure of the namespace).  Here is the actual code:
 
  for (p in nsInfo$exportPatterns)
  exports - c(ls(env, pattern = p, all.names = TRUE), exports)
 
 So to re-export a function, you need to do so explicitly.
 
 It is consdered good practice not to use exportPattern() (at least, 
 not for broadly defined patterns) in production code: see the current 
 'Writing R Extensions'.  Otherwise things may change under you (what 
 nlme exports has changed recently, hence what import(nlme) brings it 
 has).

  Thank you.
  I will transition away from using exportPattern (although it seemed
like a good quick and dirty solution to this testing problem).

  Please consider the following patch to R-exts ...

  thanks
Ben Bolker

===
--- R-exts.texi (revision 55002)
+++ R-exts.texi (working copy)
@@ -2310,7 +2310,9 @@
 package @pkg{foo} are to be imported.
 
 It is possible to export variables from a name space that it has
-imported from other name spaces.
+imported from other name spaces (they need to be exported 
+using an explicit @code{export} directive;
+i.e. @code{exportPattern} will not work).
 
 If a package only needs a few objects from another package it can use a
 fully qualified variable reference in the code instead of a formal

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


Re: [Rd] import question

2011-03-24 Thread Hadley Wickham
On Wed, Mar 23, 2011 at 7:20 PM, Ben Bolker bbol...@gmail.com wrote:
 Ben Bolker bbolker at gmail.com writes:



   I have been struggling all day to import a particular function/method
 combination (ranef(), which extracts the random effects from a mixed
 model fit) from the nlme package into another package ... so far without
 success.


  Answered my own question, finally.

  Apparently an explicit

 export(ranef)

But why do you want to export this method out of your package? (If you
export it, you will need to document it) Can't you rely on nlme being
loaded?

i.e. your test should be

library(nlme)
library(raneftest)
x - 1
class(x) - x
ranef.x(x)
ranef(x)


Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [Rd] import question

2011-03-24 Thread Ben Bolker
On 03/24/2011 03:03 PM, Hadley Wickham wrote:
 On Wed, Mar 23, 2011 at 7:20 PM, Ben Bolker bbol...@gmail.com wrote:
 Ben Bolker bbolker at gmail.com writes:



   I have been struggling all day to import a particular function/method
 combination (ranef(), which extracts the random effects from a mixed
 model fit) from the nlme package into another package ... so far without
 success.


  Answered my own question, finally.

  Apparently an explicit

 export(ranef)
 
 But why do you want to export this method out of your package? (If you
 export it, you will need to document it) Can't you rely on nlme being
 loaded?
 
 i.e. your test should be
 
 library(nlme)
 library(raneftest)
 x - 1
 class(x) - x
 ranef.x(x)
 ranef(x)


  nlme and lme4 do not play nicely together (this may be
fixable/eventually be fixed, but it's the current state of affairs), and
I want this package to interoperate with lme4.  Thus I want to avoid
explicitly loading nlme.
  Sorry I didn't make this clear initially (someone else asked about
this off-list).


  cheers
Ben

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


[Rd] Namespace dependency not required

2011-03-24 Thread Pages, Herve
Hi,

  [hpages@localhost pkgreviews]$ R-2.13 CMD check qrqc_0.99.2.tar.gz
  * using log directory ‘/home/hpages/pkgreviews/qrqc.Rcheck’
  * using R version 2.13.0 alpha (2011-03-24 r55004)
  * using platform: x86_64-unknown-linux-gnu (64-bit)
  * using session charset: UTF-8
  * checking for file ‘qrqc/DESCRIPTION’ ... OK
  * this is package ‘qrqc’ version ‘0.99.2’
  * checking package name space information ... OK
  * checking package dependencies ... ERROR
  Namespace dependency not required: RColorBrewer

How I (somewhat naively) interpret this is: it is not required
that I have this namespace dependency. In other words, R CMD check
was able to figure out that my package doesn't use anything from
RColorBrewer internally so I don't need to have this
import(RColorBrewer) directive in my NAMESPACE file.

Which is of course not what 'R CMD check' is trying to tell me.

Couldn't the message say something a little bit less misleading
i.e. something like:

  Namespace dependency not in Imports field: RColorBrewer

Thanks!
H.

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