Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Karl-Dieter Crisman
 Message: 12
 Date: Wed, 20 Apr 2011 02:09:23 -0700 (PDT)
 From: Sharpie ch...@sharpsteen.net
 To: r-devel@r-project.org
 Subject: Re: [Rd] How to get R to compile with PNG support
 Message-ID: 1303290563237-3462502.p...@n4.nabble.com
 Content-Type: text/plain; charset=UTF-8


 Dear R devel list,

 Good morning; I'm with the Sage (http://www.sagemath.org) project.
 (Some of you might have seen my talk on this at last summer's useR
 conference).

 Thanks for stoping by Karl! I have to say that I am a big fan of the Sage
 project---it is a very good idea and I really appreciate all the time you
 guys put into it. I may not be able to answer all of your questions
 concerning PNG support, but hopefully some of the following pointers will be
 useful.

Good morning, Charlie et al.,

Thanks for your words.  We like R, too!  We need to advertise it more,
and this thread is part of making sure that happens in the long run.

To the issue at hand.   Our main concern is just not to have to spend
hours reading the configuration and makefile to figure out exactly
where things happen.



 We have some rudimentary support for using R graphics in various
 cases, which has proved useful to many of our users who want to go
 back and forth between R and other capabilities within Sage.
 Unfortunately, the way we originally implemented this was using the
 png and plot functions in R itself, which perhaps isn't the best
 (i.e., everyone uses ggplot now? but I digress).


 One important distinction to make is between R graphics functions such as
 plot and ggplot, and R graphics *devices*, such as png. The devices provide
 back ends that take the R-level function calls and actually execute the
 low-level draw line from a to b, clip to rectangle A, insert left-justified
 text at x,y primitives that get written to an output format.


True.  It's the device enabling that I'm talking about.  We enable
aqua on Mac, and png on Linux.

We ignore Cairo, and ignore X11 on Mac because it is too touchy (at
least, according to the FAQ on this - different weird instructions for
each type, and of course not everyone has X on Mac).

 Bottom line for Sage is that as long as you implement at least one device
 function, such as png, your users should be able to call plot, ggplot, and
 the rest of R's graphics functions to their heart's content, they just won't
 have a wide selection of output formats.


Great.  That is okay with us; we aren't expecting (yet) people to be
able to save R graphics in various output formats.  Our native
(matplotlib) graphics, we do expect this.


 Then, not only could we be smarter in how we compile R (currently
 somewhat naively searching for /usr/include/X11/Xwindows.h to
 determine whether we'll try for png support), but we would be able to
 tell users something very precise to do (e.g., apt-get foo) if they
 currently have R without PNG support in Sage.  Again, I emphasize that
 apparently getting xorg-dev doesn't always do the trick.



 In the trac ticket you linked, the configure output shows PNG is enabled
 (I.E. the library was found) but you may be ending up with no support for an
 actual png() graphics device due to one of the following

  - configure didn't find Xlib as X11 is not listed under Interfaces
  - configure didn't find cairo as it is not listed under Additional
 capabilities

 So, although R has the PNG library that is only useful for writing PNG
 files. R also needs the Xlib or Cairo libraries to provide drawing
 primitives that will create the figures those files will contain.

Gotcha.  I suspect that the X11 not listed under Interfaces is the
problem (again, we ignore Cairo).

What is the *exact* file or directory that the R configure looks for
in trying to list X11 under Interfaces?   And is there any way around
this at all?  That is, is there any way for R to create but not
display a graphic if it has (for instance) png support, like the one
on the Trac ticket did?  We can always just search for the png file
and serve it up in our own viewers.

Note that we already search for /usr/include/X11/Xwindows.h, and
adding xorg-dev didn't help with the latest one (which may not be on
the Trac ticket).


 In the ask.sagemath question the problem appears to be that the user had X11
 installed but not libpng.

Yes, I just referenced that for reference, as it were.

Thank you, and I hope we can get this resolved!

Karl-Dieter

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


Re: [Rd] Sweave tokens not in column 1: enhancement request

2011-04-21 Thread David.Epstein

Friedrich Leisch-2 wrote:
 
 On Tue, 19 Apr 2011 13:59:44 -0700 (PDT),
 David Epstein (DE) wrote:
 
When I re-use a code chunk in Sweave, together with keep.source=TRUE,
 I would
like to follow usual programming conventions in which the amount of
 white
space on the left indicates logical structure. It seems that one can't
 do
this in Sweave, or am I wrong?
 
for (i in ind) {
do such-and-such and then
code chunk 20
do something-else
}
 
   
 Not difficult at all, that's a trivial change:
 
   MySyntax - utils::SweaveSyntaxNoweb
   MySyntax$coderef - ^[[:space:]]*(.*).*
   Sweave(test.Rnw, syntax=MySyntax)
 
 should do what you want. That code references need to start in column 1
 is inherited from noweb, not sure if we really need it. Cannot think
 of a situation where the above regular expression appears in valid R
 code, but perhaps I am overlooking something.
 

Thanks. That is indeed very simple. I should have started this thread in
R-help, as I know there are other users who would like to do this, but I
mistakenly thought that code development would be needed. Is it possible to
somehow transfer the thread to R-help?

Would it not be safer to use [:blank:] or [ \t] instead of [:space:]?
[:space:] allows several symbols apart from space and tab, and this might
cause trouble?

Is it possible to put something into the .Rnw file with the same effect, or
do you HAVE to work from outside Sweave?
Thanks
David

--
View this message in context: 
http://r.789695.n4.nabble.com/Sweave-tokens-not-in-column-1-enhancement-request-tp3461527p3463141.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] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Sean Robert McGuffee
Hi, apparently I sent my question about using R and C++ to the wrong list,
ironically seeing as that list was called Rcpp. Anyway, I was directed to
post my question here. To summarize my current question, I have found two
commands that I want to be able to put into a package. The commands are 'R
CMD SHLIB X.cc X_main.cc' and
'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
run when my package is installed and maybe have the second command run again
when my package is to be used. I've been trying to figure out the
documentation and learn through examples, but I'm just not getting it and
have been trying for weeks.
Does anyone on this site have any suggestions for me?
Thanks, Sean

|On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
| 
| 
| Hi, thanks!
| 
| On 4/20/11 10:03 AM, Steve Lianoglou mailinglist.honey...@gmail.com
wrote:
|  Hi,
|  
|  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
|  sean.mcguf...@gmail.com wrote:
|  Hi, I have a quick couple of questions about some of the documentation
on
|  the web page:
|  
http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
n
|  t_002dends-to-R
|  under the heading:
|  5.6 Interfacing C++ code
|  
|  Question 1:
|  If I¹m at a terminal, I can type the instructions they suggest:
|  R CMD SHLIB X.cc X_main.cc
|  If I wanted a package to do this, how would I tell the package to do
that
|  same thing?
|  
|  Just to make sure we're all on the same page, you want an R package to
|  compile some source code into a shared library/dll from inside R?
|  
|  Not sure if there's a baked in way for that to happen, but maybe you
|  can invoke `R CMD WHATEVER` from inside R using the `system` function:
|  
|  R ?system
|  
| 
| ok, so where in the package would I put the system call in the package to
| have it run when installing the package?

You don't. As I said, 'R CMD INSTALL' et all do that.
Download an existing package with source, install it.  Study its sources,
study the 'Writing R Extensions' manual.  Ask on r-devel.
Basic R questions are off-topic here.
 
|  Would I use the same command and just include it in a file somewhere in
the
|  package?
|  If so, which file?
|  
|  Hmm ... I'm curious what you're trying to do, exactly?
| 
| I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
| X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
| )), which are commands I can get to work for myself as a human
| interactively, and put the commands into a package to be automatically run
| when installing the package. I mean, it's great if I can compile a c++
file
| and then use it inside R, but I'm only doing that so I can let other
people
| do that via a package. As much as I read this documentation, I keep
missing

Again, I like working from an existing, working package. As I said, there are
almost 1000 to pick from.
Please direct follow-ups that have no bearing on Rcpp to r-devel.
Dirk

I've tried to figure this out for weeks by looking at other packages and
reading the confusing and nonintegrated documentation, but it hasn't taught
me how to put the two commands into a package so that they are run when the
package is installed. I'm simply trying to find out where in my package I
should put the commands 'R CMD SHLIB X.cc X_main.cc' and
'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
in order to have them run when my package is installed.


| the connections between the different sections. This is a section I am
| loving because it works very well. Thus, I want to figure out how to take
| the baby steps I'm doing and combine them into a package. Specifically, I
| want to take these two commands and insert them into a package so that
these
| commands will compile my code and make a dynamic .so file where R can
| access its functions when others install my package.
| 
|  
|  Question 2:
|  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
|  
|  Where does .Platform$dynlib.ext come from?
|  What does it mean?
|  What do it¹s components .Platform and $dynlib and .ext mean?
|  
|  .Platform is lust a normal list -- it is defined internally (I guess).
|  You can access named elements of a list with `$`.
|  
|  .Platform$dynlyb (or .Platform[['dynlib']]) tells you the extension
|  your particular system uses for shared libraries:
|  
|  R .Platform
|  $OS.type
|  [1] unix
|  
|  $file.sep
|  [1] /
|  
|  $dynlib.ext
|  [1] .so
|  
|  $GUI
|  [1] X11
|  
|  $endian
|  [1] little
|  
|  $pkgType
|  [1] mac.binary.leopard
|  
|  $path.sep
|  [1] :
|  
|  $r_arch
|  [1] x86_64
|  
|  See ?.Platform for more help.
| 
| Ah, thanks, that clarifies exactly what .Platform$dynlib.ext is, it's
.so
| on my system. 
| 
| This, the dyn.load(paste(X, .Platform$dynlib.ext, sep = )) is
equivalent
| to the command dyn.load(X.so) which now makes sense in that context!
| 
| 
| ___
| Rcpp-devel mailing list
| rcpp-de...@lists.r-forge.r-project.org
| 

[Rd] useDynLib in older versions e.g. (2.10)

2011-04-21 Thread Tobias Abenius

Hi,

Has something changed regarding the useDynLib in the NAMESPACE file in 
packages? I've written a package that works in e.g. 2.12/2.13 but simply 
cannot find the dynamic library under windows. The version on CRAN is 
older than the one I'm talking about and depends on a newer version of R 
but I want to make the package available to people with older versions.


 utils:::menuInstallLocal()
package 'lassoshooting' successfully unpacked and MD5 sums checked
 require(lassoshooting)
Loading required package: lassoshooting
Error in library.dynam(lib, package, package.lib) :
  shared library 'lassoshooting' not found
In addition: Warning message:
package 'lassoshooting' was built under R version 2.13.0

I'm usually under linux and don't know about the gory details of .dll files.

NAMESPACE file
--
useDynLib(lassoshooting)
export(lassoshooting)

happy easter!

regards, Tobias
--
Tobias Abenius
Ph.D. Student, M.Sc. in Computer Science

Mathematical Statistics
Mathematical Sciences
University of Gothenburg
* installing *source* package 'lassoshooting' ...
** libs

*** arch - i386
gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs/local/include -O3 -Wall  -std=gnu99 -c 
ccd_common.c -o ccd_common.o
ccd_common.c: In function 'ccd_common':
ccd_common.c:118:2: warning: #warning Using R fortran BLAS calls
gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs/local/include -O3 -Wall  -std=gnu99 -c 
ccd_r.c -o ccd_r.o
ccd_r.c: In function 'ccd':
ccd_r.c:163:5: warning: too many arguments for format
ccd_r.c:156:7: warning: unused variable 'ret'
ccd_r.c:18:11: warning: 'X' may be used uninitialized in this function
ccd_r.c:18:14: warning: 'y' may be used uninitialized in this function
gcc -shared -s -static-libgcc -o lassoshooting.dll tmp.def ccd_common.o ccd_r.o 
-Ld:/Rcompile/CRANpkg/extralibs/local/lib 
-LD:/RCompile/recent/R-2.13.0/bin/i386 -lRblas -lgfortran 
-LD:/RCompile/recent/R-2.13.0/bin/i386 -lR
installing to d:/RCompile/CRANguest/R-release/lib/lassoshooting/libs/i386

*** arch - x64
x86_64-w64-mingw32-gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs64new/local/include -O2 -Wall  -std=gnu99 
-c ccd_common.c -o ccd_common.o
ccd_common.c: In function 'ccd_common':
ccd_common.c:118:2: warning: #warning Using R fortran BLAS calls
x86_64-w64-mingw32-gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs64new/local/include -O2 -Wall  -std=gnu99 
-c ccd_r.c -o ccd_r.o
ccd_r.c: In function 'ccd':
ccd_r.c:163:5: warning: too many arguments for format
ccd_r.c:156:7: warning: unused variable 'ret'
ccd_r.c:18:11: warning: 'X' may be used uninitialized in this function
ccd_r.c:18:14: warning: 'y' may be used uninitialized in this function
x86_64-w64-mingw32-gcc -shared -s -static-libgcc -o lassoshooting.dll tmp.def 
ccd_common.o ccd_r.o -Ld:/Rcompile/CRANpkg/extralibs64new/local/lib 
-LD:/RCompile/recent/R-2.13.0/bin/x64 -lRblas -lgfortran 
-LD:/RCompile/recent/R-2.13.0/bin/x64 -lR
installing to d:/RCompile/CRANguest/R-release/lib/lassoshooting/libs/x64
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* MD5 sums
packaged installation of 'lassoshooting' as lassoshooting_0.1.3-6.zip

* DONE (lassoshooting)
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Karl-Dieter Crisman
Followup with the specific issue in our most recent (non-posted, as of
yet) attempts on a certain box.  We now have xorg-dev, libcairo-dev,
and Xwindows.h and libpng (as below) on this machine, but R is not
compiling with support for any of these things.

Once again, any help knowing *exactly* what to pass to the
configuration script or anything else would be *greatly* appreciated.
We are planning to use R in Sage on several occasions with this
machine this summer if we can get this going (see
http://www.maa.org/prep/2011/sage.html).



R is now configured for i686-pc-linux-gnu
 Source directory:  .
 Installation directory:/home/sageserver/sage/local
 C compiler:gcc -std=gnu99
-I/home/sageserver/sage/local/include
-L/home/sageserver/sage/local/lib/   Fortran 77 compiler:
sage_fortran  -g -O2
 C++ compiler:  g++  -g -O2
 Fortran 90/95 compiler:sage_fortran -g -O2  Obj-C compiler:
 Interfaces supported:  X11
 External libraries:readline, BLAS(ATLAS), LAPACK(generic)
Additional capabilities:   PNG, NLS
 Options enabled:   shared R library, R profiling
 Recommended packages:  yes


However:


 capabilities()
   jpeg  png tifftcltk  X11 aqua http/ftp  sockets
  FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE

 libxml fifo   clediticonv  NLS  profmemcairo
   TRUE TRUE TRUE TRUE TRUEFALSEFALSE

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


Re: [Rd] Patching update.packages to enable updating of only a user defined subset of packages

2011-04-21 Thread Tal Galili
Hi Charlie, thanks for writing back.

Using the oldPkgs parameter wouldn't work, please see the error bellow:

 update.packages(oldPkgs =c(rpart))
Error in update.packages(oldPkgs = c(rpart)) :
  invalid 'oldPkgs'; must be a result from old.packages()


Do you think it should support this instead of adding a subset parameter?


Cheers,
Tal


Contact
Details:---
Contact me: tal.gal...@gmail.com |  972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
--




On Wed, Apr 20, 2011 at 8:34 PM, Sharpie ch...@sharpsteen.net wrote:


 Tal Galili wrote:
 
  Hello dear R developers,
 
  I recently found out that it is not possible to limit update.packages()
 to
  update only a few packages at a time.
 
  The patch offered simply adds a 'subset' parameter and the statement
  bounded
  within if(!missing(subset)) to implement it.
  The code is pasted bellow (and also attached as an .r file).
 
  Might this patch be considered valuable to be added to R?
 
 
  (in the code bellow I called the function update.packages.2 so to not
  mask
  the original update.packages)
 
 
  With much respect,
  Tal
 

 Hi Tal,

 I think if you pass a character vector in the `oldPkgs` argument of
 update.packages, it will only consider packages in that list for updating.

 -Charlie


 -
 Charlie Sharpsteen
 Undergraduate-- Environmental Resources Engineering
 Humboldt State University
 --
 View this message in context:
 http://r.789695.n4.nabble.com/Patching-update-packages-to-enable-updating-of-only-a-user-defined-subset-of-packages-tp3456738p3463670.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


[[alternative HTML version deleted]]

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


Re: [Rd] useDynLib in older versions e.g. (2.10)

2011-04-21 Thread Uwe Ligges



On 20.04.2011 13:30, Tobias Abenius wrote:

Hi,

Has something changed regarding the useDynLib in the NAMESPACE file in
packages? I've written a package that works in e.g. 2.12/2.13 but simply
cannot find the dynamic library under windows. The version on CRAN is
older than the one I'm talking about and depends on a newer version of R
but I want to make the package available to people with older versions.

  utils:::menuInstallLocal()
package 'lassoshooting' successfully unpacked and MD5 sums checked
  require(lassoshooting)
Loading required package: lassoshooting
Error in library.dynam(lib, package, package.lib) :
shared library 'lassoshooting' not found
In addition: Warning message:
package 'lassoshooting' was built under R version 2.13.0



Yes, your package was built doe R-2.13.0 but you are using R = 2.12.0 
where the dll files were located in a different directory.
Hence a) time to upgrade your R version or b) Install the package from 
sources yourself for the (unstated) version of R on your Windows machine.


Uwe Ligges



I'm usually under linux and don't know about the gory details of .dll
files.

NAMESPACE file
--
useDynLib(lassoshooting)
export(lassoshooting)

happy easter!

regards, Tobias


00install.out


* installing *source* package 'lassoshooting' ...
** libs

*** arch - i386
gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs/local/include -O3 -Wall  -std=gnu99 -c ccd_common.c 
-o ccd_common.o
ccd_common.c: In function 'ccd_common':
ccd_common.c:118:2: warning: #warning Using R fortran BLAS calls
gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs/local/include -O3 -Wall  -std=gnu99 -c ccd_r.c -o 
ccd_r.o
ccd_r.c: In function 'ccd':
ccd_r.c:163:5: warning: too many arguments for format
ccd_r.c:156:7: warning: unused variable 'ret'
ccd_r.c:18:11: warning: 'X' may be used uninitialized in this function
ccd_r.c:18:14: warning: 'y' may be used uninitialized in this function
gcc -shared -s -static-libgcc -o lassoshooting.dll tmp.def ccd_common.o ccd_r.o 
-Ld:/Rcompile/CRANpkg/extralibs/local/lib 
-LD:/RCompile/recent/R-2.13.0/bin/i386 -lRblas -lgfortran 
-LD:/RCompile/recent/R-2.13.0/bin/i386 -lR
installing to d:/RCompile/CRANguest/R-release/lib/lassoshooting/libs/i386

*** arch - x64
x86_64-w64-mingw32-gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs64new/local/include -O2 -Wall  -std=gnu99 -c 
ccd_common.c -o ccd_common.o
ccd_common.c: In function 'ccd_common':
ccd_common.c:118:2: warning: #warning Using R fortran BLAS calls
x86_64-w64-mingw32-gcc -ID:/RCompile/recent/R-2.13.0/include 
-Id:/Rcompile/CRANpkg/extralibs64new/local/include -O2 -Wall  -std=gnu99 -c ccd_r.c 
-o ccd_r.o
ccd_r.c: In function 'ccd':
ccd_r.c:163:5: warning: too many arguments for format
ccd_r.c:156:7: warning: unused variable 'ret'
ccd_r.c:18:11: warning: 'X' may be used uninitialized in this function
ccd_r.c:18:14: warning: 'y' may be used uninitialized in this function
x86_64-w64-mingw32-gcc -shared -s -static-libgcc -o lassoshooting.dll tmp.def 
ccd_common.o ccd_r.o -Ld:/Rcompile/CRANpkg/extralibs64new/local/lib 
-LD:/RCompile/recent/R-2.13.0/bin/x64 -lRblas -lgfortran 
-LD:/RCompile/recent/R-2.13.0/bin/x64 -lR
installing to d:/RCompile/CRANguest/R-release/lib/lassoshooting/libs/x64
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* MD5 sums
packaged installation of 'lassoshooting' as lassoshooting_0.1.3-6.zip

* DONE (lassoshooting)



__
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] useDynLib in older versions e.g. (2.10)

2011-04-21 Thread Tobias Abenius

Dear R-devel,

I investigated further by tracing into library.dynam.
The .dll file export a symbol ccd. In e.g. R 2.8.1 the following 
command succeeds,


dyn.load('/Program 
Files/R/R-2.8.1/library/lassoshooting/libs/i386/lassoshooting.dll')


and the external symbol ccd becomes available.

However, inside library.dynam it doesn't add i386 to the path because
 .Platform$r_arch is . One way would be to re-zip the package with a 
copy of the i386 version outside of the i386 directory, directly under 
libs. That would work, but then I know I cannot commit a binary package 
to CRAN. I guess I'm not the only one having this problem.


Happy easter, Tobias
--
Tobias Abenius
Ph.D. Student, M.Sc. in Computer Science

Mathematical Statistics
Mathematical Sciences
University of Gothenburg

On 04/20/2011 01:30 PM, Tobias Abenius wrote:

Hi,

Has something changed regarding the useDynLib in the NAMESPACE file in
packages? I've written a package that works in e.g. 2.12/2.13 but simply
cannot find the dynamic library under windows. The version on CRAN is
older than the one I'm talking about and depends on a newer version of R
but I want to make the package available to people with older versions.

  utils:::menuInstallLocal()
package 'lassoshooting' successfully unpacked and MD5 sums checked
  require(lassoshooting)
Loading required package: lassoshooting
Error in library.dynam(lib, package, package.lib) :
shared library 'lassoshooting' not found
In addition: Warning message:
package 'lassoshooting' was built under R version 2.13.0

I'm usually under linux and don't know about the gory details of .dll
files.

NAMESPACE file
--
useDynLib(lassoshooting)
export(lassoshooting)
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] useDynLib in older versions e.g. (2.10)

2011-04-21 Thread Uwe Ligges



On 21.04.2011 11:30, Tobias Abenius wrote:

Dear R-devel,

I investigated further by tracing into library.dynam.
The .dll file export a symbol ccd. In e.g. R 2.8.1 the following
command succeeds,

dyn.load('/Program
Files/R/R-2.8.1/library/lassoshooting/libs/i386/lassoshooting.dll')

and the external symbol ccd becomes available.

However, inside library.dynam it doesn't add i386 to the path because
.Platform$r_arch is . One way would be to re-zip the package with a
copy of the i386 version outside of the i386 directory, directly under
libs. That would work, but then I know I cannot commit a binary package
to CRAN. I guess I'm not the only one having this problem.

Happy easter, Tobias



I think you are mislead:
CRAN accepts source packages only. Binaries are made by CRAN (or more 
particular by myself in Dortmund). For new packages or updates as of 
today, we make binaries for R-2.12.x and R-2.13.x available. Note that 
between major releases of R, you cannot assume that packages will work. 
The help system changed in R-2.10.x (and no binaries are compatible 
before vs. after the R-2.10.0 version) and the location of libraries in 
R-2.12.x changed under Windows.


If you need a binary for R-2.8.x, you will have to INSTALL from sources 
with R-2.8.x, otherwise we cannot guarantee compatibility. Note that 
R-2.8.1 is unsupported and 5 major releases back!


Uwe Ligges

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


[Rd] R CMD Sweave versus Sweave() on Windows

2011-04-21 Thread Pfaff, Bernhard Dr.
Dear list subscriber,

I am quite puzzled by the behaviour of processing Sweave files within an R 
session, i.e. 
Sweave(foo.Rnw) versus R CMD Sweave foo.Rnw

In the former the environmental variable 'SWEAVE_STYLEPATH_DEFAULT = TRUE' is 
obeyed (this is set in etc/Renviron.site as well as under the users home 
directory in .Renviron). That is the hard-coded path to Sweave.sty is included 
in the resultant tex-file, whereas if the Sweave file is processed from cmd.exe 
as R CMD Sweave foo.Rnw, only \usepackage{Sweave} is included. 

Any pointers are much appreciated.
Best,
Bernhard

Output of sessionInfo():
 sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C   
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  grDevices utils methods   base 

other attached packages:
[1] fortunes_1.4-1


Dr. Bernhard Pfaff
Director
Global Asset Allocation

Invesco Asset Management Deutschland GmbH
An der Welle 5
D-60322 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main

 
*
Confidentiality Note: The information contained in this ...{{dropped:10}}

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


Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Duncan Murdoch

On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:

Hi, apparently I sent my question about using R and C++ to the wrong list,
ironically seeing as that list was called Rcpp. Anyway, I was directed to
post my question here. To summarize my current question, I have found two
commands that I want to be able to put into a package. The commands are 'R
CMD SHLIB X.cc X_main.cc' and
'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
run when my package is installed and maybe have the second command run again
when my package is to be used. I've been trying to figure out the
documentation and learn through examples, but I'm just not getting it and
have been trying for weeks.
Does anyone on this site have any suggestions for me?


Assuming those lines work on their own, just do the following:

1.  Put those *.cc files into the src directory of your package.  (You 
may need to create it.)


2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.

3.  Call those functions using .C(X, args, PACKAGE=foo).

That's it.

Duncan Murdoch


Thanks, Sean

|On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
|
|
| Hi, thanks!
|
|On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
wrote:
|  Hi,
|
|  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
|  sean.mcguf...@gmail.com  wrote:
|  Hi, I have a quick couple of questions about some of the documentation
on
|  the web page:
|
http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
n
|  t_002dends-to-R
|  under the heading:
|  5.6 Interfacing C++ code
|
|  Question 1:
|  If I¹m at a terminal, I can type the instructions they suggest:
|  R CMD SHLIB X.cc X_main.cc
|  If I wanted a package to do this, how would I tell the package to do
that
|  same thing?
|
|  Just to make sure we're all on the same page, you want an R package to
|  compile some source code into a shared library/dll from inside R?
|
|  Not sure if there's a baked in way for that to happen, but maybe you
|  can invoke `R CMD WHATEVER` from inside R using the `system` function:
|
|  R  ?system
|
|
| ok, so where in the package would I put the system call in the package to
| have it run when installing the package?


You don't. As I said, 'R CMD INSTALL' et all do that.
Download an existing package with source, install it.  Study its sources,
study the 'Writing R Extensions' manual.  Ask on r-devel.
Basic R questions are off-topic here.


|  Would I use the same command and just include it in a file somewhere in
the
|  package?
|  If so, which file?
|
|  Hmm ... I'm curious what you're trying to do, exactly?
|
| I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
| X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
| )), which are commands I can get to work for myself as a human
| interactively, and put the commands into a package to be automatically run
| when installing the package. I mean, it's great if I can compile a c++
file
| and then use it inside R, but I'm only doing that so I can let other
people
| do that via a package. As much as I read this documentation, I keep
missing


Again, I like working from an existing, working package. As I said, there are
almost 1000 to pick from.
Please direct follow-ups that have no bearing on Rcpp to r-devel.
Dirk


I've tried to figure this out for weeks by looking at other packages and
reading the confusing and nonintegrated documentation, but it hasn't taught
me how to put the two commands into a package so that they are run when the
package is installed. I'm simply trying to find out where in my package I
should put the commands 'R CMD SHLIB X.cc X_main.cc' and
'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
in order to have them run when my package is installed.


| the connections between the different sections. This is a section I am
| loving because it works very well. Thus, I want to figure out how to take
| the baby steps I'm doing and combine them into a package. Specifically, I
| want to take these two commands and insert them into a package so that
these
| commands will compile my code and make a dynamic .so file where R can
| access its functions when others install my package.
|
|
|  Question 2:
|  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
|
|  Where does .Platform$dynlib.ext come from?
|  What does it mean?
|  What do it¹s components .Platform and $dynlib and .ext mean?
|
|  .Platform is lust a normal list -- it is defined internally (I guess).
|  You can access named elements of a list with `$`.
|
|  .Platform$dynlyb (or .Platform[['dynlib']]) tells you the extension
|  your particular system uses for shared libraries:
|
|  R  .Platform
|  $OS.type
|  [1] unix
|
|  $file.sep
|  [1] /
|
|  $dynlib.ext
|  [1] .so
|
|  $GUI
|  [1] X11
|
|  $endian
|  [1] little
|
|  $pkgType
|  [1] mac.binary.leopard
|
|  $path.sep
|  [1] :
|
|  $r_arch
|  [1] x86_64
|
|  See ?.Platform for more help.
|
| Ah, thanks, that clarifies exactly what 

Re: [Rd] R CMD Sweave versus Sweave() on Windows

2011-04-21 Thread Kasper Daniel Hansen
Bernd

.Renviron is not being read when you do R CMD ...  This is documented,
but still puzzling to me.  I solved this by using
  Sys.setenv(SWEAVE_STYLEPATH_DEFAULT = TRUE)
in my .Rprofile (which is being read by R CMD ...).  If you were on
linux you could also put it inside your shell profile (like ,.bashrc).

Kasper

On Thu, Apr 21, 2011 at 6:44 AM, Pfaff, Bernhard Dr.
bernhard_pf...@fra.invesco.com wrote:
 Dear list subscriber,

 I am quite puzzled by the behaviour of processing Sweave files within an R 
 session, i.e.
 Sweave(foo.Rnw) versus R CMD Sweave foo.Rnw

 In the former the environmental variable 'SWEAVE_STYLEPATH_DEFAULT = TRUE' is 
 obeyed (this is set in etc/Renviron.site as well as under the users home 
 directory in .Renviron). That is the hard-coded path to Sweave.sty is 
 included in the resultant tex-file, whereas if the Sweave file is processed 
 from cmd.exe as R CMD Sweave foo.Rnw, only \usepackage{Sweave} is included.

 Any pointers are much appreciated.
 Best,
 Bernhard

 Output of sessionInfo():
 sessionInfo()
 R version 2.13.0 (2011-04-13)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
 [5] LC_TIME=German_Germany.1252

 attached base packages:
 [1] stats     graphics  datasets  grDevices utils     methods   base

 other attached packages:
 [1] fortunes_1.4-1


 Dr. Bernhard Pfaff
 Director
 Global Asset Allocation

 Invesco Asset Management Deutschland GmbH
 An der Welle 5
 D-60322 Frankfurt am Main

 Tel: +49 (0)69 29807 230
 Fax: +49 (0)69 29807 178
 www.institutional.invesco.com
 Email: bernhard_pf...@fra.invesco.com

 Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
 Alexander Lehmann, Christian Puschmann
 Handelsregister: Frankfurt am Main, HRB 28469
 Sitz der Gesellschaft: Frankfurt am Main


 *
 Confidentiality Note: The information contained in this ...{{dropped:10}}

 __
 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] How to get R to compile with PNG support

2011-04-21 Thread Dirk Eddelbuettel

On 20 April 2011 at 12:16, Karl-Dieter Crisman wrote:
| 
| 
| R is now configured for i686-pc-linux-gnu
|  Source directory:  .
|  Installation directory:/home/sageserver/sage/local
|  C compiler:gcc -std=gnu99
| -I/home/sageserver/sage/local/include
| -L/home/sageserver/sage/local/lib/   Fortran 77 compiler:
| sage_fortran  -g -O2
|  C++ compiler:  g++  -g -O2
|  Fortran 90/95 compiler:sage_fortran -g -O2  Obj-C compiler:
|  Interfaces supported:  X11
|  External libraries:readline, BLAS(ATLAS), LAPACK(generic)
| Additional capabilities:   PNG, NLS
|  Options enabled:   shared R library, R profiling
|  Recommended packages:  yes
| 
| 
| However:
| 
| 
|  capabilities()
|jpeg  png tifftcltk  X11 aqua http/ftp  sockets
|   FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE
| 
|  libxml fifo   clediticonv  NLS  profmemcairo
|TRUE TRUE TRUE TRUE TRUEFALSEFALSE

Random guess: did you connect via ssh without x11 forwarding?

I cannot see how configure find png.h and libpng but the binary fails. As all
other X11 related formats are also shown false, methinks you are without a
valid DISPLAY. 

That is actually an issue related to your headless use---which is what Sage
may default too; see the R FAQ on this and the prior discussion on the
xvfb-run wrapper which 'simulates' an x11 environment (which you need for
png).  So maybe you should revisit the Cairo devices---they allow you
plotting without an x11 device (and also give you SVG).

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


Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Dirk Eddelbuettel

On 21 April 2011 at 07:16, Duncan Murdoch wrote:
| On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
|  Hi, apparently I sent my question about using R and C++ to the wrong list,
|  ironically seeing as that list was called Rcpp. Anyway, I was directed to
|  post my question here. To summarize my current question, I have found two
|  commands that I want to be able to put into a package. The commands are 'R
|  CMD SHLIB X.cc X_main.cc' and
|  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
|  run when my package is installed and maybe have the second command run again
|  when my package is to be used. I've been trying to figure out the
|  documentation and learn through examples, but I'm just not getting it and
|  have been trying for weeks.
|  Does anyone on this site have any suggestions for me?
| 
| Assuming those lines work on their own, just do the following:
| 
| 1.  Put those *.cc files into the src directory of your package.  (You 
| may need to create it.)
| 
| 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
| 
| 3.  Call those functions using .C(X, args, PACKAGE=foo).
| 
| That's it.

We told Sean this twice or three times already over in this thread 

  http://thread.gmane.org/gmane.comp.lang.r.rcpp/1808

but the message does not seem to sink in.  He keeps asking where to put 'R
CMD SHLIB' and doesn't seem to hear when we say there is none in a package...

Dirk 
 
| Duncan Murdoch
| 
|  Thanks, Sean
| 
|  |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
|  |
|  |
|  | Hi, thanks!
|  |
|  |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
|  wrote:
|  |  Hi,
|  |
|  |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
|  |  sean.mcguf...@gmail.com  wrote:
|  |  Hi, I have a quick couple of questions about some of the documentation
|  on
|  |  the web page:
|  |
|  http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
|  n
|  |  t_002dends-to-R
|  |  under the heading:
|  |  5.6 Interfacing C++ code
|  |
|  |  Question 1:
|  |  If I¹m at a terminal, I can type the instructions they suggest:
|  |  R CMD SHLIB X.cc X_main.cc
|  |  If I wanted a package to do this, how would I tell the package to do
|  that
|  |  same thing?
|  |
|  |  Just to make sure we're all on the same page, you want an R package to
|  |  compile some source code into a shared library/dll from inside R?
|  |
|  |  Not sure if there's a baked in way for that to happen, but maybe you
|  |  can invoke `R CMD WHATEVER` from inside R using the `system` function:
|  |
|  |  R  ?system
|  |
|  |
|  | ok, so where in the package would I put the system call in the package to
|  | have it run when installing the package?
| 
|  You don't. As I said, 'R CMD INSTALL' et all do that.
|  Download an existing package with source, install it.  Study its sources,
|  study the 'Writing R Extensions' manual.  Ask on r-devel.
|  Basic R questions are off-topic here.
| 
|  |  Would I use the same command and just include it in a file somewhere in
|  the
|  |  package?
|  |  If so, which file?
|  |
|  |  Hmm ... I'm curious what you're trying to do, exactly?
|  |
|  | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
|  | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
|  | )), which are commands I can get to work for myself as a human
|  | interactively, and put the commands into a package to be automatically run
|  | when installing the package. I mean, it's great if I can compile a c++
|  file
|  | and then use it inside R, but I'm only doing that so I can let other
|  people
|  | do that via a package. As much as I read this documentation, I keep
|  missing
| 
|  Again, I like working from an existing, working package. As I said, there 
are
|  almost 1000 to pick from.
|  Please direct follow-ups that have no bearing on Rcpp to r-devel.
|  Dirk
| 
|  I've tried to figure this out for weeks by looking at other packages and
|  reading the confusing and nonintegrated documentation, but it hasn't taught
|  me how to put the two commands into a package so that they are run when the
|  package is installed. I'm simply trying to find out where in my package I
|  should put the commands 'R CMD SHLIB X.cc X_main.cc' and
|  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
|  in order to have them run when my package is installed.
| 
| 
|  | the connections between the different sections. This is a section I am
|  | loving because it works very well. Thus, I want to figure out how to take
|  | the baby steps I'm doing and combine them into a package. Specifically, I
|  | want to take these two commands and insert them into a package so that
|  these
|  | commands will compile my code and make a dynamic .so file where R can
|  | access its functions when others install my package.
|  |
|  |
|  |  Question 2:
|  |  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
|  |
|  |  Where does .Platform$dynlib.ext come from?
|  |  What 

Re: [Rd] R CMD Sweave versus Sweave() on Windows

2011-04-21 Thread Prof Brian Ripley

On Thu, 21 Apr 2011, Pfaff, Bernhard Dr. wrote:


Dear list subscriber,

I am quite puzzled by the behaviour of processing Sweave files within an R 
session, i.e.
Sweave(foo.Rnw) versus R CMD Sweave foo.Rnw

In the former the environmental variable 'SWEAVE_STYLEPATH_DEFAULT = 
TRUE' is obeyed (this is set in etc/Renviron.site as well as under 
the users home directory in .Renviron). That is the hard-coded path 
to Sweave.sty is included in the resultant tex-file, whereas if the 
Sweave file is processed from cmd.exe as R CMD Sweave foo.Rnw, only 
\usepackage{Sweave} is included.


Any pointers are much appreciated.


R CMD Sweave does not read the startup files.  Try runnning 
R --vanilla and Sweave(foo.Rnw): you will see the same.



Best,
Bernhard

Output of sessionInfo():

sessionInfo()

R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252

attached base packages:
[1] stats graphics  datasets  grDevices utils methods   base

other attached packages:
[1] fortunes_1.4-1


Dr. Bernhard Pfaff
Director
Global Asset Allocation

Invesco Asset Management Deutschland GmbH
An der Welle 5
D-60322 Frankfurt am Main

Tel: +49 (0)69 29807 230
Fax: +49 (0)69 29807 178
www.institutional.invesco.com
Email: bernhard_pf...@fra.invesco.com

Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens Langewand, 
Alexander Lehmann, Christian Puschmann
Handelsregister: Frankfurt am Main, HRB 28469
Sitz der Gesellschaft: Frankfurt am Main


*
Confidentiality Note: The information contained in this ...{{dropped:10}}

__
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] BOOST libraries

2011-04-21 Thread Dirk Eddelbuettel

(Redirected from r-packages, which is supposed to be an annoucements-only
list, to r-devel which is for R development questions.)

On 21 April 2011 at 08:10, Jay Emerson wrote:
| We have used the BOOST interprocess libraries in package bigmemory
| (and synchronicity, and ...) for about 3 years now.  There is also a

RQuantLib switched to using Boost when QuantLib did in June 2004, or almost
seven years ago.

| plan (more than tentative, but yet to actually happen) to provide a
| package on CRAN that will provide these for more efficient use (having
| multiple copies floating around across separate packages seems silly).
| 
| If you are interested in this, please feel free to email me or Dirk
| (and if you are not aware of Rcpp et. al. you should have a look
| there, too).

Cedric is a list member of rcpp-devel.
 
| I would like to know whether anyone had experience using the C++ Boost
| library within an R package, and how portable was the resulting package.

Packages are perfectly portable as that is a main goal of Boost.  So in that
sense the question is misdirected; few things are as 'portable' as Boost.

The issue is more about how to ensure _binary libraries_ are found if needed
for linking.  Boost itself is a (vast) collection of libraries (in the
abstract sense of 'packages'), and only a few employ (binary) libraries. Many
can be used in a pure template sense so that only headers are needed at
compile time. 

That is what Jay refers to above:  we are contemplating creating a common
boost headers package to be used by the half dozen packages shipping their
own copies.

| I am especially thinking of possible compiling problems on Windows and
| Apple systems.
| 
| If anyone had any tips on how to render an R package using Boost
| portable, that would be very much appreciated.

Back to the issue of finding Boost libraries: you can study existing
packages.  RQuantLib for example needs to use a configure snippet and a
special case on Windows.

But in case you just want to use templates, look at RcppBDT --- an example
package using Rcpp and its 'Rcpp modules' feature to easily access Boost
Date_Time.  It by choise does not use Date Time string parsing and formatting
and hence uses only templated headers---and as such is easily buildable on
Windows, OS X, ... as the CRAN page http://cran.r-project.org/package=RcppBDT
and its links show.

Hope this helps, 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


Re: [Rd] R CMD Sweave versus Sweave() on Windows

2011-04-21 Thread Pfaff, Bernhard Dr.
 
 On Thu, 21 Apr 2011, Pfaff, Bernhard Dr. wrote:
 
  Dear list subscriber,
 
  I am quite puzzled by the behaviour of processing Sweave 
 files within an R session, i.e.
  Sweave(foo.Rnw) versus R CMD Sweave foo.Rnw
 
  In the former the environmental variable 
 'SWEAVE_STYLEPATH_DEFAULT = 
  TRUE' is obeyed (this is set in etc/Renviron.site as well 
 as under the 
  users home directory in .Renviron). That is the hard-coded path to 
  Sweave.sty is included in the resultant tex-file, whereas if the 
  Sweave file is processed from cmd.exe as R CMD Sweave foo.Rnw, only 
  \usepackage{Sweave} is included.
 
  Any pointers are much appreciated.
 
 R CMD Sweave does not read the startup files.  Try runnning R 
 --vanilla and Sweave(foo.Rnw): you will see the same.

Dear Prof. Ripley,

many thanks for your swift reply. This is indeed correct and educative --thanks 
for this; but now I am kind of curious where this different behaviour compared 
to version 2.12.0 has been announced or can be found? I have read the NEWS file 
and the Windows specific NEWS of the latest release, but was not able to find 
any pointer. That is, if I issue 'R CMD Sweave foo.Rnw' in cmd.exe with R 
version 2.12.0, the hard-coded path to Sweave.sty is included and hence 
environmental variables contained in the startup files are read.
Asked differently, is there a way such that R CMD Sweave does read the startup 
files under R 2.13.0? 

re: Kasper, many thanks for your reply. Incidentally, I have had 
'Sys.setenv(SWEAVE_STYLEPATH_DEFAULT = TRUE)' directive already included in 
my .Rprofile, but as Prof. Ripley correcly pointed out, these settings are not 
taken effect.

Best,
Bernhard  



 
  Best,
  Bernhard
 
  Output of sessionInfo():
  sessionInfo()
  R version 2.13.0 (2011-04-13)
  Platform: i386-pc-mingw32/i386 (32-bit)
 
  locale:
  [1] LC_COLLATE=German_Germany.1252  
 LC_CTYPE=German_Germany.1252 [3] 
  LC_MONETARY=German_Germany.1252 LC_NUMERIC=C [5] 
  LC_TIME=German_Germany.1252
 
  attached base packages:
  [1] stats graphics  datasets  grDevices utils methods   base
 
  other attached packages:
  [1] fortunes_1.4-1
 
 
  Dr. Bernhard Pfaff
  Director
  Global Asset Allocation
 
  Invesco Asset Management Deutschland GmbH An der Welle 5
  D-60322 Frankfurt am Main
 
  Tel: +49 (0)69 29807 230
  Fax: +49 (0)69 29807 178
  www.institutional.invesco.com
  Email: bernhard_pf...@fra.invesco.com
 
  Geschäftsführer: Karl Georg Bayer, Bernhard Langer, Dr. Jens 
  Langewand, Alexander Lehmann, Christian Puschmann
  Handelsregister: Frankfurt am Main, HRB 28469 Sitz der 
 Gesellschaft: 
  Frankfurt am Main
 
 
  *
  Confidentiality Note: The information contained in this 
  ...{{dropped:10}}
 
  __
  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] How to get R to compile with PNG support

2011-04-21 Thread Matt Shotwell

On 04/19/2011 05:00 AM, r-devel-requ...@r-project.org wrote:

Date: Mon, 18 Apr 2011 11:48:40 -0400
From: Karl-Dieter Crismankcris...@gmail.com
To:r-devel@r-project.org
Cc: Jason Groutjason.gr...@drake.edu
Subject: [Rd] How to get R to compile with PNG support
Message-ID:banlktinqz7eoe7b-gpbrcnrhcy0-bdc...@mail.gmail.com
Content-Type: text/plain; charset=windows-1252

Dear R devel list,

Good morning; I'm with the Sage (http://www.sagemath.org) project.
(Some of you might have seen my talk on this at last summer's useR
conference).

We have some rudimentary support for using R graphics in various
cases, which has proved useful to many of our users who want to go
back and forth between R and other capabilities within Sage.
Unfortunately, the way we originally implemented this was using the
png and plot functions in R itself, which perhaps isn't the best
(i.e., everyone uses ggplot now? but I digress).

That means that when people download a binary of ours, or compile
their own, whether R's plot and png functions work depends heavily on
the rather obscure (to users) issue of exactly what headers are
present on the compiling machine.

Unfortunately, it is*very*  unclear what actually needs to be present!
  There are innumerable places where this has come up for us, but
http://trac.sagemath.org/sage_trac/ticket/8868  and
http://ask.sagemath.org/question/192/compiling-r-with-png-support  are
two of the current places where people have compiled information.

The FAQ says, Unless you do not want to view graphs on-screen you
need ?X11? installed, including its headers and client libraries. For
recent Fedora distributions it means (at least) ?libX11?,
?libX11-devel?, ?libXt? and ?libXt-devel?. On Debian we recommend the
meta-package ?xorg-dev?. If you really do not want these you will need
to explicitly configure R without X11, using --with-x=no.

Well, we don't actually need to view graphs on-screen, but we do need
to be able to generate them and save them (as pngs, for instance) to
the correct directory in Sage for viewing.  But we have people who've
tried to do this in Ubuntu, with libpng and xorg-dev installed, and
the file /usr/include/X11/Xwindows.h exists, but all to no avail.
There are almost as many solutions people have found as there are
computers out there, it seems - slight hyperbole, but that's what it
feels like.

We've posted more than once (I think) to the r-help list, but have
gotten no useful feedback.  Is there*anywhere*  that the*exact*
requirements R has for having

capabilities(png)
   png
FALSE

come out TRUE are documented?


I had a similar question some time ago. The answer (of course) is in the 
code and configure macros. The main logic is in 
src/main/platform.c::do_capabilities:


SET_STRING_ELT(ansnames, i, mkChar(png));
#ifdef HAVE_PNG
# if defined Unix  !defined HAVE_WORKING_CAIRO
LOGICAL(ans)[i++] = X11;
# else /* Windows */
LOGICAL(ans)[i++] = TRUE;
# endif
#else
LOGICAL(ans)[i++] = FALSE;
#endif

---

From m4/R.m4:

if test ${use_libpng} = yes; then
  AC_CHECK_LIB(z, main, [have_png=yes], [have_png=no])
  if test ${have_png} = yes; then
_R_HEADER_PNG
have_png=${r_cv_header_png_h}
  fi
  if test ${have_png} = yes; then
AC_CHECK_LIB(png, png_create_write_struct,
 [have_png=yes],
 [have_png=no],
 [-lz ${LIBS}])
  fi
  if test ${have_png} = yes; then
BITMAP_LIBS=${BITMAP_LIBS} -lpng -lz
AC_DEFINE(HAVE_PNG, 1,
  [Define if you have the PNG headers and libraries.])
  fi
fi

---

HAVE_WORKING_CAIRO is set by m4/cairo.m4. However, the PNG function 
doesn't consult capabilities(png). Presumably capabilities(png) is 
sufficient, but you'll have to pick up the trail in the png function to 
find out what's really going on.


I've had good outcomes with cairo.


Then, not only could we be smarter in how we compile R (currently
somewhat naively searching for /usr/include/X11/Xwindows.h to
determine whether we'll try for png support), but we would be able to
tell users something very precise to do (e.g., apt-get foo) if they
currently have R without PNG support in Sage.  Again, I emphasize that
apparently getting xorg-dev doesn't always do the trick.

We do realize that for most people wanting to use just R, it's best to
download a binary, which will behave nicely; Sage's batteries
included philosophy means that we are asking for more specialized
info from upstream, and for that I apologize in advance.  I also
apologize if I said something silly above, because I don't actually
know what all these files are - I've just looked into enough support
requests to have a decent idea of what's required.We are trying
not to have to parse the makefile to figure all this out, and possibly
making some mistake there as well.

Thank you SO much for any help with this,
Karl-Dieter Crisman
for the Sage team





--
Matthew S Shotwell   Assistant 

Re: [Rd] R CMD Sweave versus Sweave() on Windows

2011-04-21 Thread Gabor Grothendieck
On Thu, Apr 21, 2011 at 6:44 AM, Pfaff, Bernhard Dr.
bernhard_pf...@fra.invesco.com wrote:
 Dear list subscriber,

 I am quite puzzled by the behaviour of processing Sweave files within an R 
 session, i.e.
 Sweave(foo.Rnw) versus R CMD Sweave foo.Rnw

 In the former the environmental variable 'SWEAVE_STYLEPATH_DEFAULT = TRUE' is 
 obeyed (this is set in etc/Renviron.site as well as under the users home 
 directory in .Renviron). That is the hard-coded path to Sweave.sty is 
 included in the resultant tex-file, whereas if the Sweave file is processed 
 from cmd.exe as R CMD Sweave foo.Rnw, only \usepackage{Sweave} is included.

 Any pointers are much appreciated.
 Best,
 Bernhard

 Output of sessionInfo():
 sessionInfo()
 R version 2.13.0 (2011-04-13)
 Platform: i386-pc-mingw32/i386 (32-bit)

 locale:
 [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
 [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
 [5] LC_TIME=German_Germany.1252

 attached base packages:
 [1] stats     graphics  datasets  grDevices utils     methods   base

 other attached packages:
 [1] fortunes_1.4-1


SWEAVE_STYLEPATH_DEFAULT is automatically set in Sweave.bat found here
(its part of the batchfiles distribution but does not require any
other batch file in order to run it):

http://batchfiles.googlecode.com/svn/trunk/Sweave.bat

This was only just added and has not been tested yet but if anyone
would like to try it just put it anywhere on your Windows PATH (or
current directory) and issue a command like this from the Windows
console:

   Sweave myfile.Rnw



-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

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


Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Karl-Dieter Crisman
Thanks for your replies, Dirk and Matt.

On Thu, Apr 21, 2011 at 7:49 AM, Dirk Eddelbuettel e...@debian.org wrote:

 On 20 April 2011 at 12:16, Karl-Dieter Crisman wrote:
 | 
 |
 | R is now configured for i686-pc-linux-gnu
 |  Source directory:          .
 |  Installation directory:    /home/sageserver/sage/local
 |  C compiler:                gcc -std=gnu99
 | -I/home/sageserver/sage/local/include
 | -L/home/sageserver/sage/local/lib/   Fortran 77 compiler:
 | sage_fortran  -g -O2
 |  C++ compiler:              g++  -g -O2
 |  Fortran 90/95 compiler:    sage_fortran -g -O2  Obj-C compiler:
 |  Interfaces supported:      X11
 |  External libraries:        readline, BLAS(ATLAS), LAPACK(generic)
 | Additional capabilities:   PNG, NLS
 |  Options enabled:           shared R library, R profiling
 |  Recommended packages:      yes
 |
 |
 | However:
 |
 |
 |  capabilities()
 |    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets
 |   FALSE    FALSE    FALSE    FALSE    FALSE    FALSE     TRUE     TRUE
 |
 |  libxml     fifo   cledit    iconv      NLS  profmem    cairo
 |    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE    FALSE

 Random guess: did you connect via ssh without x11 forwarding?

Almost certainly, yes.  (I am an interlocutor right now for someone
who is actually doing this, my apologies.)
But it's a machine we just ssh into, I'm pretty sure, though it does
serve up web pages.

 I cannot see how configure find png.h and libpng but the binary fails. As all
 other X11 related formats are also shown false, methinks you are without a
 valid DISPLAY.

That is quite likely.  So it sounds like for png() to be set to use
the X11 device, there has to (somewhere) be a visual output -
presumably that is the part LOGICAL(ans)[i++] = X11; in Matt's answer.

 That is actually an issue related to your headless use---which is what Sage
 may default too; see the R FAQ on this and the prior discussion on the
 xvfb-run wrapper which 'simulates' an x11 environment (which you need for
 png).  So maybe you should revisit the Cairo devices---they allow you
 plotting without an x11 device (and also give you SVG).


Yeah, and I saw your SO answer on this (after the fact) as well.

In some sense, we are just trying to get graphics on one machine.
Note that we have installed the cairo devel package on this very
machine, but it's not being picked up - maybe it's looking in the
wrong place?  That is one of the reasons this is confusing.

But in a larger sense, because of Sage's batteries included
philosophy (which we know not everyone agrees with!), we would like to
have a one-shot way so that *everyone* will see R graphics, not just
people whose binary happens to have been compiled on a machine that
has X and a display.  If that means adding 22.5 MB to our tarball for
Cairo... maybe, maybe not.

I won't copy Matt's message here, but I appreciate the pointers to
exactly where these things are defined very much - without knowing
where to look, it would be a long slog.   Hopefully we'll have some
success!  Thanks for the replies, and for any other ideas.

Karl-Dieter

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


Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Dirk Eddelbuettel

On 21 April 2011 at 09:51, Karl-Dieter Crisman wrote:
| Thanks for your replies, Dirk and Matt.

My pleasure. 
 
| On Thu, Apr 21, 2011 at 7:49 AM, Dirk Eddelbuettel e...@debian.org wrote:
|  Random guess: did you connect via ssh without x11 forwarding?
| 
| Almost certainly, yes.  (I am an interlocutor right now for someone
| who is actually doing this, my apologies.)
| But it's a machine we just ssh into, I'm pretty sure, though it does
| serve up web pages.
[...]
| In some sense, we are just trying to get graphics on one machine.
| Note that we have installed the cairo devel package on this very
| machine, but it's not being picked up - maybe it's looking in the
| wrong place?  That is one of the reasons this is confusing.

You have to understand that even though this problem may seem urgent and
novel to you and the Sage team, it is actually about as old as the web and R
itself.  In a nutshell, we all (in the people reading r-help and r-devel
sense) have been explaining to folks since the late 1990s that in order to
run png() to 'just create some charts for a webserver' ... you need an X11
server because that is where the font metrics come from. Or else no png for
you.

| But in a larger sense, because of Sage's batteries included
| philosophy (which we know not everyone agrees with!), we would like to
| have a one-shot way so that *everyone* will see R graphics, not just
| people whose binary happens to have been compiled on a machine that
| has X and a display.  If that means adding 22.5 MB to our tarball for
| Cairo... maybe, maybe not.

As they say: There is no such thing as a free lunch.  

Pick an X11 server (to be able to launch the 'xvfb-run' wrapper) for font
metrics, or run something else like Cairo. Neither one is real cheap.  Such
is life.  System such as Sage become so large because having things like this
around on all deployment systems implies (at least to some degree)
replicating fundamental OS level features because they unfortunately have
supply things missing or broken across OSs.

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


Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Simon Urbanek

On Apr 21, 2011, at 9:51 AM, Karl-Dieter Crisman wrote:

 Thanks for your replies, Dirk and Matt.
 
 On Thu, Apr 21, 2011 at 7:49 AM, Dirk Eddelbuettel e...@debian.org wrote:
 
 On 20 April 2011 at 12:16, Karl-Dieter Crisman wrote:
 | 
 |
 | R is now configured for i686-pc-linux-gnu
 |  Source directory:  .
 |  Installation directory:/home/sageserver/sage/local
 |  C compiler:gcc -std=gnu99
 | -I/home/sageserver/sage/local/include
 | -L/home/sageserver/sage/local/lib/   Fortran 77 compiler:
 | sage_fortran  -g -O2
 |  C++ compiler:  g++  -g -O2
 |  Fortran 90/95 compiler:sage_fortran -g -O2  Obj-C compiler:
 |  Interfaces supported:  X11
 |  External libraries:readline, BLAS(ATLAS), LAPACK(generic)
 | Additional capabilities:   PNG, NLS
 |  Options enabled:   shared R library, R profiling
 |  Recommended packages:  yes
 |
 |
 | However:
 |
 |
 |  capabilities()
 |jpeg  png tifftcltk  X11 aqua http/ftp  sockets
 |   FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE
 |
 |  libxml fifo   clediticonv  NLS  profmemcairo
 |TRUE TRUE TRUE TRUE TRUEFALSEFALSE
 
 Random guess: did you connect via ssh without x11 forwarding?
 
 Almost certainly, yes.  (I am an interlocutor right now for someone
 who is actually doing this, my apologies.)
 But it's a machine we just ssh into, I'm pretty sure, though it does
 serve up web pages.
 
 I cannot see how configure find png.h and libpng but the binary fails. As all
 other X11 related formats are also shown false, methinks you are without a
 valid DISPLAY.
 
 That is quite likely.  So it sounds like for png() to be set to use
 the X11 device, there has to (somewhere) be a visual output -
 presumably that is the part LOGICAL(ans)[i++] = X11; in Matt's answer.
 
 That is actually an issue related to your headless use---which is what Sage
 may default too; see the R FAQ on this and the prior discussion on the
 xvfb-run wrapper which 'simulates' an x11 environment (which you need for
 png).  So maybe you should revisit the Cairo devices---they allow you
 plotting without an x11 device (and also give you SVG).
 
 
 Yeah, and I saw your SO answer on this (after the fact) as well.
 
 In some sense, we are just trying to get graphics on one machine.
 Note that we have installed the cairo devel package on this very
 machine, but it's not being picked up - maybe it's looking in the
 wrong place?  That is one of the reasons this is confusing.
 
 But in a larger sense, because of Sage's batteries included
 philosophy (which we know not everyone agrees with!), we would like to
 have a one-shot way so that *everyone* will see R graphics, not just
 people whose binary happens to have been compiled on a machine that
 has X and a display.  If that means adding 22.5 MB to our tarball for
 Cairo... maybe, maybe not.
 

Maybe yes in that case - that's what we do in Mac binaries -- and on Mac users 
always expect  batteries included so we include libcairo statically. (The 
same applies for R packages like Cairo which provides png support independent 
of X11).

Cheers,
Simon


 I won't copy Matt's message here, but I appreciate the pointers to
 exactly where these things are defined very much - without knowing
 where to look, it would be a long slog.   Hopefully we'll have some
 success!  Thanks for the replies, and for any other ideas.
 
 Karl-Dieter
 
 __
 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] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Sean Robert McGuffee
Thanks,
That's great, but I don't know how to determine what foo is. How do I
declare the name of the package?


On 4/21/11 7:16 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:

 On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
 Hi, apparently I sent my question about using R and C++ to the wrong list,
 ironically seeing as that list was called Rcpp. Anyway, I was directed to
 post my question here. To summarize my current question, I have found two
 commands that I want to be able to put into a package. The commands are 'R
 CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
 run when my package is installed and maybe have the second command run again
 when my package is to be used. I've been trying to figure out the
 documentation and learn through examples, but I'm just not getting it and
 have been trying for weeks.
 Does anyone on this site have any suggestions for me?
 
 Assuming those lines work on their own, just do the following:
 
 1.  Put those *.cc files into the src directory of your package.  (You
 may need to create it.)
 
 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
 
 3.  Call those functions using .C(X, args, PACKAGE=foo).
 
 That's it.
 
 Duncan Murdoch
 
 Thanks, Sean
 
 |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
 |
 |
 | Hi, thanks!
 |
 |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
 wrote:
 |  Hi,
 |
 |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
 |  sean.mcguf...@gmail.com  wrote:
 |  Hi, I have a quick couple of questions about some of the documentation
 on
 |  the web page:
 |
 http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
 n
 |  t_002dends-to-R
 |  under the heading:
 |  5.6 Interfacing C++ code
 |
 |  Question 1:
 |  If I¹m at a terminal, I can type the instructions they suggest:
 |  R CMD SHLIB X.cc X_main.cc
 |  If I wanted a package to do this, how would I tell the package to do
 that
 |  same thing?
 |
 |  Just to make sure we're all on the same page, you want an R package to
 |  compile some source code into a shared library/dll from inside R?
 |
 |  Not sure if there's a baked in way for that to happen, but maybe you
 |  can invoke `R CMD WHATEVER` from inside R using the `system` function:
 |
 |  R  ?system
 |
 |
 | ok, so where in the package would I put the system call in the package to
 | have it run when installing the package?
 
 You don't. As I said, 'R CMD INSTALL' et all do that.
 Download an existing package with source, install it.  Study its sources,
 study the 'Writing R Extensions' manual.  Ask on r-devel.
 Basic R questions are off-topic here.
 
 |  Would I use the same command and just include it in a file somewhere in
 the
 |  package?
 |  If so, which file?
 |
 |  Hmm ... I'm curious what you're trying to do, exactly?
 |
 | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
 | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
 | )), which are commands I can get to work for myself as a human
 | interactively, and put the commands into a package to be automatically run
 | when installing the package. I mean, it's great if I can compile a c++
 file
 | and then use it inside R, but I'm only doing that so I can let other
 people
 | do that via a package. As much as I read this documentation, I keep
 missing
 
 Again, I like working from an existing, working package. As I said, there
 are
 almost 1000 to pick from.
 Please direct follow-ups that have no bearing on Rcpp to r-devel.
 Dirk
 
 I've tried to figure this out for weeks by looking at other packages and
 reading the confusing and nonintegrated documentation, but it hasn't taught
 me how to put the two commands into a package so that they are run when the
 package is installed. I'm simply trying to find out where in my package I
 should put the commands 'R CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
 in order to have them run when my package is installed.
 
 
 | the connections between the different sections. This is a section I am
 | loving because it works very well. Thus, I want to figure out how to take
 | the baby steps I'm doing and combine them into a package. Specifically, I
 | want to take these two commands and insert them into a package so that
 these
 | commands will compile my code and make a dynamic .so file where R can
 | access its functions when others install my package.
 |
 |
 |  Question 2:
 |  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
 |
 |  Where does .Platform$dynlib.ext come from?
 |  What does it mean?
 |  What do it¹s components .Platform and $dynlib and .ext mean?
 |
 |  .Platform is lust a normal list -- it is defined internally (I guess).
 |  You can access named elements of a list with `$`.
 |
 |  .Platform$dynlyb (or .Platform[['dynlib']]) tells you the extension
 |  your particular system uses for shared libraries:
 |
 |  R  .Platform
 |  

Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Simon Urbanek

On Apr 21, 2011, at 10:52 AM, Sean Robert McGuffee wrote:

 Thanks,
 That's great, but I don't know how to determine what foo is.

It's the name of your package.


 How do I declare the name of the package?
 

in DESCRIPTION:
Package: name

and the directory of your package has to have the same name - please do read
http://r.research.att.com/man/R-exts.html#Creating-R-packages

Cheers,
Simon


 
 On 4/21/11 7:16 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
 
 On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
 Hi, apparently I sent my question about using R and C++ to the wrong list,
 ironically seeing as that list was called Rcpp. Anyway, I was directed to
 post my question here. To summarize my current question, I have found two
 commands that I want to be able to put into a package. The commands are 'R
 CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
 run when my package is installed and maybe have the second command run again
 when my package is to be used. I've been trying to figure out the
 documentation and learn through examples, but I'm just not getting it and
 have been trying for weeks.
 Does anyone on this site have any suggestions for me?
 
 Assuming those lines work on their own, just do the following:
 
 1.  Put those *.cc files into the src directory of your package.  (You
 may need to create it.)
 
 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
 
 3.  Call those functions using .C(X, args, PACKAGE=foo).
 
 That's it.
 
 Duncan Murdoch
 
 Thanks, Sean
 
 |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
 |
 |
 | Hi, thanks!
 |
 |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
 wrote:
 |  Hi,
 |
 |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
 |  sean.mcguf...@gmail.com  wrote:
 |  Hi, I have a quick couple of questions about some of the documentation
 on
 |  the web page:
 |
 http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
 n
 |  t_002dends-to-R
 |  under the heading:
 |  5.6 Interfacing C++ code
 |
 |  Question 1:
 |  If I’m at a terminal, I can type the instructions they suggest:
 |  R CMD SHLIB X.cc X_main.cc
 |  If I wanted a package to do this, how would I tell the package to do
 that
 |  same thing?
 |
 |  Just to make sure we're all on the same page, you want an R package to
 |  compile some source code into a shared library/dll from inside R?
 |
 |  Not sure if there's a baked in way for that to happen, but maybe you
 |  can invoke `R CMD WHATEVER` from inside R using the `system` function:
 |
 |  R  ?system
 |
 |
 | ok, so where in the package would I put the system call in the package to
 | have it run when installing the package?
 
 You don't. As I said, 'R CMD INSTALL' et all do that.
 Download an existing package with source, install it.  Study its sources,
 study the 'Writing R Extensions' manual.  Ask on r-devel.
 Basic R questions are off-topic here.
 
 |  Would I use the same command and just include it in a file somewhere in
 the
 |  package?
 |  If so, which file?
 |
 |  Hmm ... I'm curious what you're trying to do, exactly?
 |
 | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
 | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
 | )), which are commands I can get to work for myself as a human
 | interactively, and put the commands into a package to be automatically run
 | when installing the package. I mean, it's great if I can compile a c++
 file
 | and then use it inside R, but I'm only doing that so I can let other
 people
 | do that via a package. As much as I read this documentation, I keep
 missing
 
 Again, I like working from an existing, working package. As I said, there
 are
 almost 1000 to pick from.
 Please direct follow-ups that have no bearing on Rcpp to r-devel.
 Dirk
 
 I've tried to figure this out for weeks by looking at other packages and
 reading the confusing and nonintegrated documentation, but it hasn't taught
 me how to put the two commands into a package so that they are run when the
 package is installed. I'm simply trying to find out where in my package I
 should put the commands 'R CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
 in order to have them run when my package is installed.
 
 
 | the connections between the different sections. This is a section I am
 | loving because it works very well. Thus, I want to figure out how to take
 | the baby steps I'm doing and combine them into a package. Specifically, I
 | want to take these two commands and insert them into a package so that
 these
 | commands will compile my code and make a dynamic .so file where R can
 | access its functions when others install my package.
 |
 |
 |  Question 2:
 |  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
 |
 |  Where does .Platform$dynlib.ext come from?
 |  What does it mean?
 |  What do it’s components .Platform and $dynlib and .ext mean?
 |
 

Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Duncan Murdoch

On 21/04/2011 10:52 AM, Sean Robert McGuffee wrote:

Thanks,
That's great, but I don't know how to determine what foo is. How do I
declare the name of the package?


See the Writing R Extensions manual, or a tutorial on the topic, e.g. 
the one I gave at UseR 2008, available here:


www.r-project.org/conferences/*useR-2008*/slides/*Murdoch*.pdf
*
*It contains a few things that are no longer true (e.g. you don't need 
Perl any more), but is mostly still accurate.


Duncan Murdoch


On 4/21/11 7:16 AM, Duncan Murdochmurdoch.dun...@gmail.com  wrote:

  On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
  Hi, apparently I sent my question about using R and C++ to the wrong list,
  ironically seeing as that list was called Rcpp. Anyway, I was directed to
  post my question here. To summarize my current question, I have found two
  commands that I want to be able to put into a package. The commands are 'R
  CMD SHLIB X.cc X_main.cc' and
  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
  run when my package is installed and maybe have the second command run again
  when my package is to be used. I've been trying to figure out the
  documentation and learn through examples, but I'm just not getting it and
  have been trying for weeks.
  Does anyone on this site have any suggestions for me?

  Assuming those lines work on their own, just do the following:

  1.  Put those *.cc files into the src directory of your package.  (You
  may need to create it.)

  2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.

  3.  Call those functions using .C(X, args, PACKAGE=foo).

  That's it.

  Duncan Murdoch

  Thanks, Sean

  |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
  |
  |
  | Hi, thanks!
  |
  |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
  wrote:
  |   Hi,
  |
  |   On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
  |   sean.mcguf...@gmail.com   wrote:
  |   Hi, I have a quick couple of questions about some of the documentation
  on
  |   the web page:
  |
  http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
  n
  |   t_002dends-to-R
  |   under the heading:
  |   5.6 Interfacing C++ code
  |
  |   Question 1:
  |   If I¹m at a terminal, I can type the instructions they suggest:
  |   R CMD SHLIB X.cc X_main.cc
  |   If I wanted a package to do this, how would I tell the package to do
  that
  |   same thing?
  |
  |   Just to make sure we're all on the same page, you want an R package to
  |   compile some source code into a shared library/dll from inside R?
  |
  |   Not sure if there's a baked in way for that to happen, but maybe you
  |   can invoke `R CMD WHATEVER` from inside R using the `system` function:
  |
  |   R   ?system
  |
  |
  | ok, so where in the package would I put the system call in the package to
  | have it run when installing the package?

  You don't. As I said, 'R CMD INSTALL' et all do that.
  Download an existing package with source, install it.  Study its sources,
  study the 'Writing R Extensions' manual.  Ask on r-devel.
  Basic R questions are off-topic here.

  |   Would I use the same command and just include it in a file somewhere 
in
  the
  |   package?
  |   If so, which file?
  |
  |   Hmm ... I'm curious what you're trying to do, exactly?
  |
  | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
  | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
  | )), which are commands I can get to work for myself as a human
  | interactively, and put the commands into a package to be automatically run
  | when installing the package. I mean, it's great if I can compile a c++
  file
  | and then use it inside R, but I'm only doing that so I can let other
  people
  | do that via a package. As much as I read this documentation, I keep
  missing

  Again, I like working from an existing, working package. As I said, there
  are
  almost 1000 to pick from.
  Please direct follow-ups that have no bearing on Rcpp to r-devel.
  Dirk

  I've tried to figure this out for weeks by looking at other packages and
  reading the confusing and nonintegrated documentation, but it hasn't taught
  me how to put the two commands into a package so that they are run when the
  package is installed. I'm simply trying to find out where in my package I
  should put the commands 'R CMD SHLIB X.cc X_main.cc' and
  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
  in order to have them run when my package is installed.


  | the connections between the different sections. This is a section I am
  | loving because it works very well. Thus, I want to figure out how to take
  | the baby steps I'm doing and combine them into a package. Specifically, I
  | want to take these two commands and insert them into a package so that
  these
  | commands will compile my code and make a dynamic .so file where R can
  | access its functions when others install my package.
  |
  |
  |   

Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Simon Urbanek

On Apr 20, 2011, at 8:35 AM, Karl-Dieter Crisman wrote:

 Message: 12
 Date: Wed, 20 Apr 2011 02:09:23 -0700 (PDT)
 From: Sharpie ch...@sharpsteen.net
 To: r-devel@r-project.org
 Subject: Re: [Rd] How to get R to compile with PNG support
 Message-ID: 1303290563237-3462502.p...@n4.nabble.com
 Content-Type: text/plain; charset=UTF-8
 
 
 Dear R devel list,
 
 Good morning; I'm with the Sage (http://www.sagemath.org) project.
 (Some of you might have seen my talk on this at last summer's useR
 conference).
 
 Thanks for stoping by Karl! I have to say that I am a big fan of the Sage
 project---it is a very good idea and I really appreciate all the time you
 guys put into it. I may not be able to answer all of your questions
 concerning PNG support, but hopefully some of the following pointers will be
 useful.
 
 Good morning, Charlie et al.,
 
 Thanks for your words.  We like R, too!  We need to advertise it more,
 and this thread is part of making sure that happens in the long run.
 
 To the issue at hand.   Our main concern is just not to have to spend
 hours reading the configuration and makefile to figure out exactly
 where things happen.
 
 
 
 We have some rudimentary support for using R graphics in various
 cases, which has proved useful to many of our users who want to go
 back and forth between R and other capabilities within Sage.
 Unfortunately, the way we originally implemented this was using the
 png and plot functions in R itself, which perhaps isn't the best
 (i.e., everyone uses ggplot now? but I digress).
 
 
 One important distinction to make is between R graphics functions such as
 plot and ggplot, and R graphics *devices*, such as png. The devices provide
 back ends that take the R-level function calls and actually execute the
 low-level draw line from a to b, clip to rectangle A, insert left-justified
 text at x,y primitives that get written to an output format.
 
 
 True.  It's the device enabling that I'm talking about.  We enable
 aqua on Mac, and png on Linux.
 
 We ignore Cairo, and ignore X11 on Mac because it is too touchy (at
 least, according to the FAQ on this - different weird instructions for
 each type, and of course not everyone has X on Mac).
 

FWIW this seem a little outdated - all recent OS X come with X11 installed and 
libcairo is not a problem to build ...


 Bottom line for Sage is that as long as you implement at least one device
 function, such as png, your users should be able to call plot, ggplot, and
 the rest of R's graphics functions to their heart's content, they just won't
 have a wide selection of output formats.
 
 
 Great.  That is okay with us; we aren't expecting (yet) people to be
 able to save R graphics in various output formats.  Our native
 (matplotlib) graphics, we do expect this.
 
 
 Then, not only could we be smarter in how we compile R (currently
 somewhat naively searching for /usr/include/X11/Xwindows.h to
 determine whether we'll try for png support), but we would be able to
 tell users something very precise to do (e.g., apt-get foo) if they
 currently have R without PNG support in Sage.  Again, I emphasize that
 apparently getting xorg-dev doesn't always do the trick.
 
 
 
 In the trac ticket you linked, the configure output shows PNG is enabled
 (I.E. the library was found) but you may be ending up with no support for an
 actual png() graphics device due to one of the following
 
  - configure didn't find Xlib as X11 is not listed under Interfaces
  - configure didn't find cairo as it is not listed under Additional
 capabilities
 
 So, although R has the PNG library that is only useful for writing PNG
 files. R also needs the Xlib or Cairo libraries to provide drawing
 primitives that will create the figures those files will contain.
 
 Gotcha.  I suspect that the X11 not listed under Interfaces is the
 problem (again, we ignore Cairo).
 
 What is the *exact* file or directory that the R configure looks for
 in trying to list X11 under Interfaces?   And is there any way around
 this at all?  That is, is there any way for R to create but not
 display a graphic if it has (for instance) png support, like the one
 on the Trac ticket did?  We can always just search for the png file
 and serve it up in our own viewers.
 
 Note that we already search for /usr/include/X11/Xwindows.h, and
 adding xorg-dev didn't help with the latest one (which may not be on
 the Trac ticket).
 

I missed which distro you're using, but xorg-dev is likely insufficient (by 
design). For example on Debian you'll also need libxt-dev. Note that your best 
friend is config.log and the output of configure - that tells *exactly* what 
you're missing. You will need at least X11, ICE, Xt libraries and 
X11/Intrinsic.h headers. 

Cheers,
Simon


 In the ask.sagemath question the problem appears to be that the user had X11
 installed but not libpng.
 
 Yes, I just referenced that for reference, as it were.
 
 Thank you, and I hope we can get this resolved!
 
 Karl-Dieter
 
 

Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Sean Robert McGuffee

So, how is the package turning it's name into those commands?
Does the installation automatically list the src directory and iteratively
run a loop over each file and call 'R CMD SHLIB objectOfIterator' ?
The reason this is so important is because it¹s easy to get things to work
via a terminal command 'R CMD SHLIB someSourceFile.cpp¹, so I want to be
able to take things that work that way and put them inside a package. It
seems peculiar to me that R needs to access functions through a C wrapper
too. I¹m not sure why it can¹t access C++ functions directly. What R is
doing is over my head because it is calling functions that were not compiled
into it. I mean, if I want to call a C or C++ function from C++ code, I have
to convince my compiler that I have a header and all definitions behind the
declarations in my source files to compile my own programs. I don¹t know how
R works when the program is compiled way in advance and is then somehow
calling on declarations made later in another place. I think objective C/C++
allows for this type of thing where you can write code to call something
that is declared but not yet defined. However, I¹m not sure what R is doing?
Is R doing the same thing a compiler would do and creating it¹s own binary
instructions for the launch of a function, or is it creating a new
executable and launching that as it¹s own application and then somehow
communicating with it?
Sean 


On 4/21/11 7:52 AM, Dirk Eddelbuettel e...@debian.org wrote:

 
 On 21 April 2011 at 07:16, Duncan Murdoch wrote:
 | On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
 |  Hi, apparently I sent my question about using R and C++ to the wrong list,
 |  ironically seeing as that list was called Rcpp. Anyway, I was directed to
 |  post my question here. To summarize my current question, I have found two
 |  commands that I want to be able to put into a package. The commands are 'R
 |  CMD SHLIB X.cc X_main.cc' and
 |  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
 |  run when my package is installed and maybe have the second command run
 again
 |  when my package is to be used. I've been trying to figure out the
 |  documentation and learn through examples, but I'm just not getting it and
 |  have been trying for weeks.
 |  Does anyone on this site have any suggestions for me?
 | 
 | Assuming those lines work on their own, just do the following:
 | 
 | 1.  Put those *.cc files into the src directory of your package.  (You
 | may need to create it.)
 | 
 | 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
 | 
 | 3.  Call those functions using .C(X, args, PACKAGE=foo).
 | 
 | That's it.
 
 We told Sean this twice or three times already over in this thread
 
   http://thread.gmane.org/gmane.comp.lang.r.rcpp/1808
 
 but the message does not seem to sink in.  He keeps asking where to put 'R
 CMD SHLIB' and doesn't seem to hear when we say there is none in a package...
 
 Dirk 
  
 | Duncan Murdoch
 | 
 |  Thanks, Sean
 | 
 |  |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
 |  |
 |  |
 |  | Hi, thanks!
 |  |
 |  |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
 |  wrote:
 |  |  Hi,
 |  |
 |  |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
 |  |  sean.mcguf...@gmail.com  wrote:
 |  |  Hi, I have a quick couple of questions about some of the
 documentation
 |  on
 |  |  the web page:
 |  |
 |  
 http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
 |  n
 |  |  t_002dends-to-R
 |  |  under the heading:
 |  |  5.6 Interfacing C++ code
 |  |
 |  |  Question 1:
 |  |  If I¹m at a terminal, I can type the instructions they suggest:
 |  |  R CMD SHLIB X.cc X_main.cc
 |  |  If I wanted a package to do this, how would I tell the package to do
 |  that
 |  |  same thing?
 |  |
 |  |  Just to make sure we're all on the same page, you want an R package to
 |  |  compile some source code into a shared library/dll from inside R?
 |  |
 |  |  Not sure if there's a baked in way for that to happen, but maybe you
 |  |  can invoke `R CMD WHATEVER` from inside R using the `system` function:
 |  |
 |  |  R  ?system
 |  |
 |  |
 |  | ok, so where in the package would I put the system call in the package
 to
 |  | have it run when installing the package?
 | 
 |  You don't. As I said, 'R CMD INSTALL' et all do that.
 |  Download an existing package with source, install it.  Study its sources,
 |  study the 'Writing R Extensions' manual.  Ask on r-devel.
 |  Basic R questions are off-topic here.
 | 
 |  |  Would I use the same command and just include it in a file somewhere
 in
 |  the
 |  |  package?
 |  |  If so, which file?
 |  |
 |  |  Hmm ... I'm curious what you're trying to do, exactly?
 |  |
 |  | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
 |  | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
 |  | )), which are commands I can get to work for myself as a human
 |  | interactively, and put 

Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Sean Robert McGuffee

Ah, that's simple, thanks!

On 4/21/11 10:57 AM, Simon Urbanek simon.urba...@r-project.org wrote:

 
 On Apr 21, 2011, at 10:52 AM, Sean Robert McGuffee wrote:
 
 Thanks,
 That's great, but I don't know how to determine what foo is.
 
 It's the name of your package.
 
 
 How do I declare the name of the package?
 
 
 in DESCRIPTION:
 Package: name
 
 and the directory of your package has to have the same name - please do read
 http://r.research.att.com/man/R-exts.html#Creating-R-packages
 
 Cheers,
 Simon
 
 
 
 On 4/21/11 7:16 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
 
 On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
 Hi, apparently I sent my question about using R and C++ to the wrong list,
 ironically seeing as that list was called Rcpp. Anyway, I was directed to
 post my question here. To summarize my current question, I have found two
 commands that I want to be able to put into a package. The commands are 'R
 CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
 run when my package is installed and maybe have the second command run
 again
 when my package is to be used. I've been trying to figure out the
 documentation and learn through examples, but I'm just not getting it and
 have been trying for weeks.
 Does anyone on this site have any suggestions for me?
 
 Assuming those lines work on their own, just do the following:
 
 1.  Put those *.cc files into the src directory of your package.  (You
 may need to create it.)
 
 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
 
 3.  Call those functions using .C(X, args, PACKAGE=foo).
 
 That's it.
 
 Duncan Murdoch
 
 Thanks, Sean
 
 |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
 |
 |
 | Hi, thanks!
 |
 |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
 wrote:
 |  Hi,
 |
 |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
 |  sean.mcguf...@gmail.com  wrote:
 |  Hi, I have a quick couple of questions about some of the documentation
 on
 |  the web page:
 |
 
http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fr
o
 n
 |  t_002dends-to-R
 |  under the heading:
 |  5.6 Interfacing C++ code
 |
 |  Question 1:
 |  If I¹m at a terminal, I can type the instructions they suggest:
 |  R CMD SHLIB X.cc X_main.cc
 |  If I wanted a package to do this, how would I tell the package to do
 that
 |  same thing?
 |
 |  Just to make sure we're all on the same page, you want an R package to
 |  compile some source code into a shared library/dll from inside R?
 |
 |  Not sure if there's a baked in way for that to happen, but maybe you
 |  can invoke `R CMD WHATEVER` from inside R using the `system` function:
 |
 |  R  ?system
 |
 |
 | ok, so where in the package would I put the system call in the package to
 | have it run when installing the package?
 
 You don't. As I said, 'R CMD INSTALL' et all do that.
 Download an existing package with source, install it.  Study its sources,
 study the 'Writing R Extensions' manual.  Ask on r-devel.
 Basic R questions are off-topic here.
 
 |  Would I use the same command and just include it in a file somewhere
 in
 the
 |  package?
 |  If so, which file?
 |
 |  Hmm ... I'm curious what you're trying to do, exactly?
 |
 | I'm trying to figure out how take commands such as  R CMD SHLIB X.cc
 | X_main.cc followed by dyn.load(paste(X, .Platform$dynlib.ext, sep =
 | )), which are commands I can get to work for myself as a human
 | interactively, and put the commands into a package to be automatically
 run
 | when installing the package. I mean, it's great if I can compile a c++
 file
 | and then use it inside R, but I'm only doing that so I can let other
 people
 | do that via a package. As much as I read this documentation, I keep
 missing
 
 Again, I like working from an existing, working package. As I said, there
 are
 almost 1000 to pick from.
 Please direct follow-ups that have no bearing on Rcpp to r-devel.
 Dirk
 
 I've tried to figure this out for weeks by looking at other packages and
 reading the confusing and nonintegrated documentation, but it hasn't taught
 me how to put the two commands into a package so that they are run when the
 package is installed. I'm simply trying to find out where in my package I
 should put the commands 'R CMD SHLIB X.cc X_main.cc' and
 'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),'
 in order to have them run when my package is installed.
 
 
 | the connections between the different sections. This is a section I am
 | loving because it works very well. Thus, I want to figure out how to take
 | the baby steps I'm doing and combine them into a package. Specifically, I
 | want to take these two commands and insert them into a package so that
 these
 | commands will compile my code and make a dynamic .so file where R can
 | access its functions when others install my package.
 |
 |
 |  Question 2:
 |  dyn.load(paste(X, .Platform$dynlib.ext, sep = ))
 |
 |  Where does 

Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Joshua Ulrich
Please, please, please read the documentation before sending more
questions to the list.  You also have the source code, so you can look
at what R CMD build and R CMD INSTALL are doing.
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Thu, Apr 21, 2011 at 10:16 AM, Sean Robert McGuffee
sean.mcguf...@gmail.com wrote:

 So, how is the package turning it's name into those commands?
 Does the installation automatically list the src directory and iteratively
 run a loop over each file and call 'R CMD SHLIB objectOfIterator' ?
 The reason this is so important is because itšs easy to get things to work
 via a terminal command 'R CMD SHLIB someSourceFile.cppš, so I want to be
 able to take things that work that way and put them inside a package. It
 seems peculiar to me that R needs to access functions through a C wrapper
 too. Išm not sure why it canšt access C++ functions directly. What R is
 doing is over my head because it is calling functions that were not compiled
 into it. I mean, if I want to call a C or C++ function from C++ code, I have
 to convince my compiler that I have a header and all definitions behind the
 declarations in my source files to compile my own programs. I donšt know how
 R works when the program is compiled way in advance and is then somehow
 calling on declarations made later in another place. I think objective C/C++
 allows for this type of thing where you can write code to call something
 that is declared but not yet defined. However, Išm not sure what R is doing?
 Is R doing the same thing a compiler would do and creating itšs own binary
 instructions for the launch of a function, or is it creating a new
 executable and launching that as itšs own application and then somehow
 communicating with it?
 Sean


 On 4/21/11 7:52 AM, Dirk Eddelbuettel e...@debian.org wrote:


 On 21 April 2011 at 07:16, Duncan Murdoch wrote:
 | On 11-04-20 11:33 AM, Sean Robert McGuffee wrote:
 |  Hi, apparently I sent my question about using R and C++ to the wrong 
 list,
 |  ironically seeing as that list was called Rcpp. Anyway, I was directed to
 |  post my question here. To summarize my current question, I have found two
 |  commands that I want to be able to put into a package. The commands are 
 'R
 |  CMD SHLIB X.cc X_main.cc' and
 |  'dyn.load(paste(X,.Platform$dynlib.ext,sep=)),' which I would like to
 |  run when my package is installed and maybe have the second command run
 again
 |  when my package is to be used. I've been trying to figure out the
 |  documentation and learn through examples, but I'm just not getting it and
 |  have been trying for weeks.
 |  Does anyone on this site have any suggestions for me?
 |
 | Assuming those lines work on their own, just do the following:
 |
 | 1.  Put those *.cc files into the src directory of your package.  (You
 | may need to create it.)
 |
 | 2.  Put useDynLib(foo) into the NAMESPACE file of your foo package.
 |
 | 3.  Call those functions using .C(X, args, PACKAGE=foo).
 |
 | That's it.

 We told Sean this twice or three times already over in this thread

   http://thread.gmane.org/gmane.comp.lang.r.rcpp/1808

 but the message does not seem to sink in.  He keeps asking where to put 'R
 CMD SHLIB' and doesn't seem to hear when we say there is none in a package...

 Dirk

 | Duncan Murdoch
 |
 |  Thanks, Sean
 | 
 |  |On 20 April 2011 at 10:20, Sean Robert McGuffee wrote:
 |  |
 |  |
 |  | Hi, thanks!
 |  |
 |  |On 4/20/11 10:03 AM, Steve Lianogloumailinglist.honey...@gmail.com
 |  wrote:
 |  |  Hi,
 |  |
 |  |  On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
 |  |  sean.mcguf...@gmail.com  wrote:
 |  |  Hi, I have a quick couple of questions about some of the
 documentation
 |  on
 |  |  the web page:
 |  |
 | 
 http://cran.r-project.org/doc/manuals/R-exts.html#Linking-GUIs-and-other-fro
 |  n
 |  |  t_002dends-to-R
 |  |  under the heading:
 |  |  5.6 Interfacing C++ code
 |  |
 |  |  Question 1:
 |  |  If Išm at a terminal, I can type the instructions they suggest:
 |  |  R CMD SHLIB X.cc X_main.cc
 |  |  If I wanted a package to do this, how would I tell the package to do
 |  that
 |  |  same thing?
 |  |
 |  |  Just to make sure we're all on the same page, you want an R package 
 to
 |  |  compile some source code into a shared library/dll from inside R?
 |  |
 |  |  Not sure if there's a baked in way for that to happen, but maybe 
 you
 |  |  can invoke `R CMD WHATEVER` from inside R using the `system` 
 function:
 |  |
 |  |  R  ?system
 |  |
 |  |
 |  | ok, so where in the package would I put the system call in the package
 to
 |  | have it run when installing the package?
 | 
 |  You don't. As I said, 'R CMD INSTALL' et all do that.
 |  Download an existing package with source, install it.  Study its 
 sources,
 |  study the 'Writing R Extensions' manual.  Ask on r-devel.
 |  Basic R questions are off-topic here.
 | 
 |  |  Would I use the same command and just include it in a file somewhere
 in
 |  the
 |  |  package?
 

Re: [Rd] How to get R to compile with PNG support

2011-04-21 Thread Karl-Dieter Crisman
Thanks for all the feedback.  First, our update, then two responses.

From Jason Grout:
+++
I finally got it working.  After mucking around in the R configure
file a bit and trying out some of the different tests, as well as
comparing a working system with our broken system, I realized that
`pkg-config --exists pangocairo` was working on the good system and
not working on the broken system.  So I installed libpango1.0-dev, and
now R picks up the cairo package, which in turn means that my
capabilities is now:

 capabilities()
   jpeg  png tifftcltk  X11 aqua http/ftp  sockets
   TRUE TRUEFALSEFALSEFALSEFALSE TRUE TRUE
 libxml fifo   clediticonv  NLS  profmemcairo
   TRUE TRUE TRUE TRUE TRUEFALSE TRUE

So in short, I think what I did was install libcairo-dev and
libpango1.0-dev.  There might have been other stuff in there that was
needed; I'm not sure.  When I build a new system again, I'll try just
installing those packages and see if it is sufficient.  For the
record, I had also installed xorg-dev as well.

+++
My comment: As someone who didn't know what configure scripts were a
couple years ago, this is maddening; I don't see anything about
libpango or whatever in the FAQs.  Luckily, Jason knows a lot more
than I do!

@Dirk:

 | Note that we have installed the cairo devel package on this very
 | machine, but it's not being picked up - maybe it's looking in the
 | wrong place?  That is one of the reasons this is confusing.

 You have to understand that even though this problem may seem urgent and
 novel to you and the Sage team,

Novel, yes; urgent only to us, certainly we don't assume it's urgent to you :)

 it is actually about as old as the web and R
 itself.  In a nutshell, we all (in the people reading r-help and r-devel
 sense) have been explaining to folks since the late 1990s that in order to
 run png() to 'just create some charts for a webserver' ... you need an X11
 server because that is where the font metrics come from. Or else no png for

It's true this is findable, but the difference between having X11 on
the system and having the display is arcane for those who just want to
use R.  But I understand your point.

 is life.  System such as Sage become so large because having things like this
 around on all deployment systems implies (at least to some degree)
 replicating fundamental OS level features because they unfortunately have
 supply things missing or broken across OSs.

Yes, that is true.  We know of many people who download Sage because
it's the easiest way to install Z, where Z is some specific
mathematical program that is impossible to configure properly without
special knowledge.  Or, until fairly recently, to get Cython.

@Simon:

That's new to me that X11 is installed by default now, but it looks
like you are right.  However, we don't rely on this for Mac; we make
sure to configure for quartz when we build - which I assume is
separate from the other stuff?  But updating the FAQ about this would
be really great for future users :)

Also thanks for the hint on all the other (possibly) needed stuff.
Yikes!  AFAIK this is an Ubuntu machine we're talking about.

To all - if we come up with any more reliable way to make this work
universally, i.e. with *exact* instructions for what to download, we
will definitely pass that upstream. Thank you.

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


Re: [Rd] Sweave support added to rgl package

2011-04-21 Thread Duncan Murdoch
I've just committed some changes to rgl that will probably detect 
bitmaps that are specified to be too large.  As well, Brian Ripley 
backported some of the R-devel additions to the RweaveLatex driver, so 
now R 2.13.0-patched (revision 55572 or newer) should

work as well as R-devel.

Duncan Murdoch

On 20/04/2011 8:56 PM, Duncan Murdoch wrote:

On 20/04/2011 7:10 PM, Dominick Samperi wrote:
  On Wed, Apr 20, 2011 at 2:29 PM, Duncan Murdoch
  murdoch.dun...@gmail.com   wrote:
  On 20/04/2011 1:52 PM, Dominick Samperi wrote:

  On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch
  murdoch.dun...@gmail.com wrote:
I have just committed some code to the rgl package on
https://r-forge.r-project.org/projects/rgl/ to allow rgl images to be
inserted into Sweave documents.  (This is not in the CRAN version yet.)
It
makes use of the custom graphics driver support added by Brian Ripley.

In R-devel (which will become R 2.14.0 next spring in New Zealand, next
  fall
in most other places), usage is quite straightforward.  For
example, code like this in a Sweave document:

fig=true, grdevice=rgl.Sweave, pdf=false, stayopen=TRUE=
x- rnorm(100); y- rnorm(100); z- rnorm(100)
plot3d(x, y, z)
@

will insert a .png snapshot of the figure.  Because that chunk has
stayopen=TRUE, it can be followed by another chunk to add
to the figure, e.g.

fig=true, grdevice=rgl.Sweave, pdf=false=
lines3d(x[1:10], y[1:10], z[1:10], col=red)
@

All of this is possible in R 2.13.0, but it takes more work:  see the
?rgl.Sweave help page.

I will eventually add postscript and PDF output options as well, and
  perhaps
some support for the LaTeX movie15 package, but those are not there
  yet.
  Comments or bug reports are welcome.

Duncan Murdoch

  I inserted your example into testrgl.Rnw under R 2.13.0, with
  Sweave.snapshot()
  at the end of both chunks, but things did not work as expected.

  I used:
  $ R CMD Sweave testrgl.Rnw
  $ pdflatex tesetrgl
  (view testrgl.pdf)

  When R CMD Sweave is run the graphics is displayed interactively.

  That's unavoidable as far as I know.  I don't think there's a general
  purpose way to tell OpenGL to render in the background, so it works by
  rendering on screen, then copying a bitmap to the .png file.

  There is no graphics in the PDF file, even though both .png files
  are read when pdflatex is run.

  Do they look okay?  One possible problem is that you may have asked for a
  bitmap too big for your hardware to render, in which case those png files
  will end up with junk (probably blank).  Setting resolution=100 in the chunk
  headers will do it more coarsely.  (The default is 300 dpi.)  The same
  effect comes from width=1, height=1  (or some other small numbers).

  Duncan Murdoch


  The resolution=100 tip fixed the problem, thanks.

I'll see if I am skipping over some error message in there.  It would be
much better for Sweave to fail with an error than generate empty images.


Now I see the snapshots
  in the PDF file. Using this in a package will certainly change the
  user experience,
  but it moves away from the traditional batch-oriented R package
  processing, it seems to me.

I don't follow that.

  The idea of adding support for movies and 3D graphics to Sweave/PDF files
  sounds very interesting and revolutionary.

Movies will likely be pretty slow.  I think you'll want caching of some
sort if you want to produce those.

Duncan Murdoch


  Dominick



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


[Rd] problem subsetting of a reference class

2011-04-21 Thread A Zege
I am trying to define subset operator for a reference class and hitting some
problem i am unable to diagnose.To give an example, here is a toy class
generator that is a wrapper around a list




tmpGEN-setRefClass(TMP, fields=list(
namelist=list
))
tmpGEN$methods('add'=function(obj, name){
namelist[[name]]-obj
})

tmpGEN$methods('['=function(name){
if(class(name)!=character)
stop('to return cache element need to pass its 
name')
ind-match(name, names(namelist))
if(is.na(ind))
stop('data to remove is not in namelist')
namelist[[name]]
})


==

when i try to use it, the following happens
v-rnorm(10)
tmp-tmpGEN$new()
tmp$add(v, 'random')

. up until here everything is ok, class is generated and vector is
added. Now when i do
tmp['random']

i get error message 

Error in tmp[random] : object of type 'S4' is not subsettable

Not sure if it means that i cannot define [ operator for a class or if i
am doing it syntactically wrong


--
View this message in context: 
http://r.789695.n4.nabble.com/problem-subsetting-of-a-reference-class-tp3466690p3466690.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] problem subsetting of a reference class

2011-04-21 Thread John Chambers

You're confusing functional and OOP-style methods.

Since you define an OOP-style method, you need to invoke it in OOP style.

With your example:


 tmp$`[`(random)
 [1] -1.439131143 -0.630354726  0.822006263 -0.651707539  0.475332681
 [6]  0.002680224  1.539035675 -0.117609566  2.066227300  1.111270997



You could if you wanted define a functional method via setMethod() to 
allow functional access, by invoking the $`[`() method--preferably after 
changing its name.  It's probably a matter of opinion whether that's a 
good use of OOP-style methods.



On 4/21/11 12:24 PM, A Zege wrote:

I am trying to define subset operator for a reference class and hitting some
problem i am unable to diagnose.To give an example, here is a toy class
generator that is a wrapper around a list




tmpGEN-setRefClass(TMP, fields=list(
namelist=list
))
tmpGEN$methods('add'=function(obj, name){
namelist[[name]]-obj
})

tmpGEN$methods('['=function(name){
if(class(name)!=character)
stop('to return cache element need to pass its 
name')
ind-match(name, names(namelist))
if(is.na(ind))
stop('data to remove is not in namelist')
namelist[[name]]
})


==

when i try to use it, the following happens
v-rnorm(10)
tmp-tmpGEN$new()
tmp$add(v, 'random')

. up until here everything is ok, class is generated and vector is
added. Now when i do
tmp['random']

i get error message

Error in tmp[random] : object of type 'S4' is not subsettable

Not sure if it means that i cannot define [ operator for a class or if i
am doing it syntactically wrong


--
View this message in context: 
http://r.789695.n4.nabble.com/problem-subsetting-of-a-reference-class-tp3466690p3466690.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


Re: [Rd] FW: [Rcpp-devel] Question on 5.6 Interfacing C++ code

2011-04-21 Thread Sharpie

smcguffee wrote:
 
 You are right, I looked and I did find the R source code. However, it's
 largely written in R! I mean, I don't know how to trace the R code where
 INSTALL is recognized and follow it to a c or c++ level command. For
 example
 these are hits in .R files, not c files, and I don't know how to connect
 
 ...
 
 If you could point me to the functions that are called a c or c++ level,
 I'd
 love to see what R is doing for myself.
 Thanks!
 Sean
 

Hi Sean!

Along with many other people in this thread, I would strongly recommend a
top-down approach to this. Build a package, stick some stuff in the src
folder, run R CMD INSTALL on it and see what happens. The reason I recommend
this approach is that it lets you focus on writing a package that does
something useful rather than the nuts and bolts of cross platform
compilation and installation. R CMD INSTALL takes care of this for you
automagically and it is very good at what it does.

I wrote a post some time back about building an example package from scratch
that contains C code:

http://r.789695.n4.nabble.com/Writing-own-simulation-function-in-C-td1580190.html#a1580423

It begins with the using the package.skeleton() function to kickstart
things, discusses how to make sure the compiled code is dynamically loaded
when a user runs library(your_package) and even discusses how to call R
functions from inside of C functions and vice-versa. The example code is
still available and I'm sure it could be generalized to C++ quite easily. 
There are also some other responses in that thread that offer useful advice.


At the beginning it is just best to treat R CMD INSTALL as a magical unicorn
that gets you where you need to go:

http://abstrusegoose.com/120
(keep clicking the images to get the full story)


If you are absolutely, positively dying to know what really happens... well,
the relative files in the R source are `src/library/tools/R/install.R` and
`src/library/tools/R/build.R`.


But seriously. Magical unicorn. Takes care of the hard stuff so you can
build awesome packages.

Hope this helps!

-Charlie

-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
--
View this message in context: 
http://r.789695.n4.nabble.com/FW-Rcpp-devel-Question-on-5-6-Interfacing-C-code-tp3465257p3467221.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