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

2011-04-20 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" 
wrote:
| > Hi,
| > 
| > On Wed, Apr 20, 2011 at 9:49 AM, Sean Robert McGuffee
| >  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!
| 
| 
| _

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

2011-04-20 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
>   > <>
>   > 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


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

2011-04-20 Thread Karl-Dieter Crisman
> Message: 12
> Date: Wed, 20 Apr 2011 02:09:23 -0700 (PDT)
> From: Sharpie 
> 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 support added to rgl package

2011-04-20 Thread Duncan Murdoch

On 20/04/2011 7:10 PM, Dominick Samperi wrote:

On Wed, Apr 20, 2011 at 2:29 PM, Duncan Murdoch
  wrote:

On 20/04/2011 1:52 PM, Dominick Samperi wrote:


On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch
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:

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

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


Re: [Rd] Sweave support added to rgl package

2011-04-20 Thread Dominick Samperi
On Wed, Apr 20, 2011 at 2:29 PM, Duncan Murdoch
 wrote:
> On 20/04/2011 1:52 PM, Dominick Samperi wrote:
>>
>> On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch
>>   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:
>> >
>> >  <>=
>> >  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.
>> >
>> >  <>=
>> >  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. 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.

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

Dominick

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


Re: [Rd] possible minor bug in fisher.test

2011-04-20 Thread peter dalgaard

On Apr 20, 2011, at 21:30 , Fay, Michael (NIH/NIAID) [E] wrote:

> Hi,
> 
> I received a bug report for my exact2x2 package that seems to apply to 
> fisher.test in the stats package also.
> 
> Here is some code which creates the error:
> 
>> x<-factor(c(0,1,1),levels=c(0,1))
>> y<-factor(c(1,1,1),levels=c(0,1))
>> fisher.test(x,y)
> Error in fisher.test(x, y) : 'x' and 'y' must have at least 2 levels
>> 
> 
> The help says that x and y could be factors, and technically y does have 2 
> levels, although both are not observed. There is no problem statistically 
> with y not having 2 observed levels,  and
> 
>> fisher.test(table(x,y))
> 
> Produces the correct p-value of 1 and no errors.
> 
> There is an easy solution. In fisher.test replace
> 
>x <- factor(x[OK])
>y <- factor(y[OK])
> 
> 
> with
> 
>x <- as.factor(x[OK])
>y <- as.factor(y[OK])
> 
> (similar to how it is done in mcnemar.test).
> 
> 

OK. Of course, the test makes little sense statistically either way if one 
factor has only one level used, but I can imagine that a p value of 1 is 
preferable to an error, and the consistency is probably worth having too.

Fixed in r-devel.

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

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


[Rd] possible minor bug in fisher.test

2011-04-20 Thread Fay, Michael (NIH/NIAID) [E]
Hi,

 I received a bug report for my exact2x2 package that seems to apply to 
fisher.test in the stats package also.

Here is some code which creates the error:

>x<-factor(c(0,1,1),levels=c(0,1))
> y<-factor(c(1,1,1),levels=c(0,1))
> fisher.test(x,y)
Error in fisher.test(x, y) : 'x' and 'y' must have at least 2 levels
>

The help says that x and y could be factors, and technically y does have 2 
levels, although both are not observed. There is no problem statistically with 
y not having 2 observed levels,  and

> fisher.test(table(x,y))

Produces the correct p-value of 1 and no errors.

There is an easy solution. In fisher.test replace

x <- factor(x[OK])
y <- factor(y[OK])


with

x <- as.factor(x[OK])
y <- as.factor(y[OK])

(similar to how it is done in mcnemar.test).


Mike


**
Michael P. Fay, PhD
Mathematical Statistician
National Institute of Allergy and Infectious Diseases
Tel: 301-451-5124   Fax:301-480-0912
(U.S. postal mail address)
6700B Rockledge Drive MSC 7609
Bethesda, MD 20892-7609
(Overnight mail address)
6700-A Rockledge Drive, Room 5133
Bethesda, MD 20817
http://www3.niaid.nih.gov/about/organization/dcr/BRB/staff/michael.htm
**
Disclaimer:
The information in this e-mail and any of its attachment...{{dropped:11}}

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


Re: [Rd] Make as.factor an S3 generic?

2011-04-20 Thread Martin Morgan

On 04/20/2011 11:38 AM, Prof Brian Ripley wrote:

Well, lots of functions are not generic. We do ask you to give a case
for such changes ... where is it?


The specific need started with base::lapply, which calls base::as.list. 
An S4 method "as.list,A-method" defined in a name space isn't seen by 
base::as.list, whereas as.list.A is (see discussion in ?Methods around 
/f3.myClass). The question is from this post on a Bioconductor mailing list


https://stat.ethz.ch/pipermail/bioc-sig-sequencing/2011-April/001979.html

[partly answering Bill's question here] A list() constructor could be 
tricky to implement (dealing with variable numbers of arguments and the 
S4 rules for dispatch on ...), whereas as.list.A is trivial (slot 
extraction, in my case). Having arrived at an easy solution, I marched 
through the other coercion functions with only minor set-backs 
(as.double.A instead of as.numeric.A) until factor.


Martin



On Wed, 20 Apr 2011, Martin Morgan wrote:


as.factor / as.ordered is not written as a generic. This differs from
as.numeric, as.matrix, and other as.*. The following seems to address
this and does not break make check-all.

FWIW, the patch is against r55563, because with r55564 I see


OS-specific 


/home/mtmorgan/src/R-devel/src/main/dounzip.c:75:15: error: storage
size of ‘dt’ isn’t known
/home/mtmorgan/src/R-devel/src/main/dounzip.c:88:5: warning: implicit
declaration of function ‘mktime’
make[3]: *** [dounzip.o] Error 1
make[3]: *** Waiting for unfinished jobs
make[3]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/mtmorgan/bin/R-devel/src'
make: *** [R] Error 1


Index: src/library/base/R/factor.R
===
--- src/library/base/R/factor.R (revision 55563)
+++ src/library/base/R/factor.R (working copy)
@@ -45,7 +45,9 @@
}

is.factor <- function(x) inherits(x, "factor")
-as.factor <- function(x) if (is.factor(x)) x else factor(x)
+as.factor.default <- function(x, ...)
+ if (is.factor(x)) x else factor(x, ...)
+as.factor <- function(x, ...) UseMethod("as.factor")

## Help old S users:
category <- function(...) .Defunct()
@@ -245,7 +247,10 @@
ordered <- function(x, ...) factor(x, ..., ordered=TRUE)

is.ordered <- function(x) inherits(x, "ordered")
-as.ordered <- function(x) if(is.ordered(x)) x else ordered(x)
+as.ordered.default <- function(x, ...)
+ if(is.ordered(x)) x else ordered(x, ...)
+as.ordered <- function(x, ...)
+ UseMethod("as.ordered")

Ops.ordered <- function (e1, e2)
{
Index: src/library/base/man/factor.Rd
===
--- src/library/base/man/factor.Rd (revision 55563)
+++ src/library/base/man/factor.Rd (working copy)
@@ -10,7 +10,9 @@
\alias{is.factor}
\alias{is.ordered}
\alias{as.factor}
+\alias{as.factor.default}
\alias{as.ordered}
+\alias{as.ordered.default}
\alias{is.na<-.factor}
\alias{Math.factor}
\alias{Ops.factor}
@@ -40,8 +42,8 @@
is.factor(x)
is.ordered(x)

-as.factor(x)
-as.ordered(x)
+as.factor(x, \dots)
+as.ordered(x, \dots)

addNA(x, ifany=FALSE)
}

--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

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






--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

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


Re: [Rd] Make as.factor an S3 generic?

2011-04-20 Thread Prof Brian Ripley
Well, lots of functions are not generic.  We do ask you to give a case 
for such changes ... where is it?


On Wed, 20 Apr 2011, Martin Morgan wrote:

as.factor / as.ordered is not written as a generic. This differs from 
as.numeric, as.matrix, and other as.*. The following seems to address this 
and does not break make check-all.


FWIW, the patch is against r55563, because with r55564 I see


OS-specific 

/home/mtmorgan/src/R-devel/src/main/dounzip.c:75:15: error: storage size of 
‘dt’ isn’t known
/home/mtmorgan/src/R-devel/src/main/dounzip.c:88:5: warning: implicit 
declaration of function ‘mktime’

make[3]: *** [dounzip.o] Error 1
make[3]: *** Waiting for unfinished jobs
make[3]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/mtmorgan/bin/R-devel/src'
make: *** [R] Error 1


Index: src/library/base/R/factor.R
===
--- src/library/base/R/factor.R (revision 55563)
+++ src/library/base/R/factor.R (working copy)
@@ -45,7 +45,9 @@
}

is.factor <- function(x) inherits(x, "factor")
-as.factor <- function(x) if (is.factor(x)) x else factor(x)
+as.factor.default <- function(x, ...)
+if (is.factor(x)) x else factor(x, ...)
+as.factor <- function(x, ...) UseMethod("as.factor")

## Help old S users:
category <- function(...) .Defunct()
@@ -245,7 +247,10 @@
ordered <- function(x, ...) factor(x, ..., ordered=TRUE)

is.ordered <- function(x) inherits(x, "ordered")
-as.ordered <- function(x) if(is.ordered(x)) x else ordered(x)
+as.ordered.default <- function(x, ...)
+if(is.ordered(x)) x else ordered(x, ...)
+as.ordered <- function(x, ...)
+UseMethod("as.ordered")

Ops.ordered <- function (e1, e2)
{
Index: src/library/base/man/factor.Rd
===
--- src/library/base/man/factor.Rd  (revision 55563)
+++ src/library/base/man/factor.Rd  (working copy)
@@ -10,7 +10,9 @@
\alias{is.factor}
\alias{is.ordered}
\alias{as.factor}
+\alias{as.factor.default}
\alias{as.ordered}
+\alias{as.ordered.default}
\alias{is.na<-.factor}
\alias{Math.factor}
\alias{Ops.factor}
@@ -40,8 +42,8 @@
is.factor(x)
is.ordered(x)

-as.factor(x)
-as.ordered(x)
+as.factor(x, \dots)
+as.ordered(x, \dots)

addNA(x, ifany=FALSE)
}

--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

__
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] Make as.factor an S3 generic?

2011-04-20 Thread Martin Morgan

On 04/20/2011 10:13 AM, William Dunlap wrote:

-Original Message-
From: r-devel-boun...@r-project.org
[mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Morgan
Sent: Wednesday, April 20, 2011 9:56 AM
To: R-devel@r-project.org
Subject: [Rd] Make as.factor an S3 generic?

as.factor / as.ordered is not written as a generic. This differs from
as.numeric, as.matrix, and other as.*. The following seems to address
this and does not break make check-all.


Why did you decide to make as.factor() generic instead of factor()?


Hi Bill --

short-sighted consistency with other as.*; implied simplicity of 
coercion rather than construction.


Martin



Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com



--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

__
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-20 Thread Duncan Murdoch

On 20/04/2011 1:28 PM, Sharpie wrote:

Duncan Murdoch-2 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:
>
>  <>=
>  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.
>
>  <>=
>  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
>

This is great news Duncan!

If you do consider adding support for movie15, the Asymptote graphics
language may be handy:

http://asymptote.sourceforge.net/

Asymptote can embed 3D graphs into LaTeX documents that are fully
zoomable/manipulatable. It also uses LaTeX to typeset the figure text.


Thanks.  That doesn't look easy, but it would indeed be a nice addition.

Duncan Murdoch



-Charlie


-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
--
View this message in context: 
http://r.789695.n4.nabble.com/Sweave-support-added-to-rgl-package-tp3461163p3463653.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] Sweave support added to rgl package

2011-04-20 Thread Duncan Murdoch

On 20/04/2011 1:52 PM, Dominick Samperi wrote:

On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch
  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:
>
>  <>=
>  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.
>
>  <>=
>  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

__
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-20 Thread Dominick Samperi
On Tue, Apr 19, 2011 at 2:18 PM, Duncan Murdoch
 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:
>
> <>=
> 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.
>
> <>=
> 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.

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

Thanks,
Dominick

__
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-20 Thread Sharpie

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


Re: [Rd] Sweave support added to rgl package

2011-04-20 Thread Sharpie

Duncan Murdoch-2 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:
> 
> <>=
> 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.
> 
> <>=
> 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
> 

This is great news Duncan!

If you do consider adding support for movie15, the Asymptote graphics
language may be handy:

http://asymptote.sourceforge.net/

Asymptote can embed 3D graphs into LaTeX documents that are fully
zoomable/manipulatable. It also uses LaTeX to typeset the figure text.

-Charlie


-
Charlie Sharpsteen
Undergraduate-- Environmental Resources Engineering
Humboldt State University
--
View this message in context: 
http://r.789695.n4.nabble.com/Sweave-support-added-to-rgl-package-tp3461163p3463653.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] Make as.factor an S3 generic?

2011-04-20 Thread William Dunlap
> -Original Message-
> From: r-devel-boun...@r-project.org 
> [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Morgan
> Sent: Wednesday, April 20, 2011 9:56 AM
> To: R-devel@r-project.org
> Subject: [Rd] Make as.factor an S3 generic?
> 
> as.factor / as.ordered is not written as a generic. This differs from 
> as.numeric, as.matrix, and other as.*. The following seems to address 
> this and does not break make check-all.

Why did you decide to make as.factor() generic instead of factor()?

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

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


[Rd] Make as.factor an S3 generic?

2011-04-20 Thread Martin Morgan
as.factor / as.ordered is not written as a generic. This differs from 
as.numeric, as.matrix, and other as.*. The following seems to address 
this and does not break make check-all.


FWIW, the patch is against r55563, because with r55564 I see

/home/mtmorgan/src/R-devel/src/main/dounzip.c:75:15: error: storage size 
of ‘dt’ isn’t known
/home/mtmorgan/src/R-devel/src/main/dounzip.c:88:5: warning: implicit 
declaration of function ‘mktime’

make[3]: *** [dounzip.o] Error 1
make[3]: *** Waiting for unfinished jobs
make[3]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[2]: *** [R] Error 2
make[2]: Leaving directory `/home/mtmorgan/bin/R-devel/src/main'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/home/mtmorgan/bin/R-devel/src'
make: *** [R] Error 1


Index: src/library/base/R/factor.R
===
--- src/library/base/R/factor.R (revision 55563)
+++ src/library/base/R/factor.R (working copy)
@@ -45,7 +45,9 @@
 }

 is.factor <- function(x) inherits(x, "factor")
-as.factor <- function(x) if (is.factor(x)) x else factor(x)
+as.factor.default <- function(x, ...)
+if (is.factor(x)) x else factor(x, ...)
+as.factor <- function(x, ...) UseMethod("as.factor")

 ## Help old S users:
 category <- function(...) .Defunct()
@@ -245,7 +247,10 @@
 ordered <- function(x, ...) factor(x, ..., ordered=TRUE)

 is.ordered <- function(x) inherits(x, "ordered")
-as.ordered <- function(x) if(is.ordered(x)) x else ordered(x)
+as.ordered.default <- function(x, ...)
+if(is.ordered(x)) x else ordered(x, ...)
+as.ordered <- function(x, ...)
+UseMethod("as.ordered")

 Ops.ordered <- function (e1, e2)
 {
Index: src/library/base/man/factor.Rd
===
--- src/library/base/man/factor.Rd  (revision 55563)
+++ src/library/base/man/factor.Rd  (working copy)
@@ -10,7 +10,9 @@
 \alias{is.factor}
 \alias{is.ordered}
 \alias{as.factor}
+\alias{as.factor.default}
 \alias{as.ordered}
+\alias{as.ordered.default}
 \alias{is.na<-.factor}
 \alias{Math.factor}
 \alias{Ops.factor}
@@ -40,8 +42,8 @@
 is.factor(x)
 is.ordered(x)

-as.factor(x)
-as.ordered(x)
+as.factor(x, \dots)
+as.ordered(x, \dots)

 addNA(x, ifany=FALSE)
 }

--
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

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


Re: [Rd] self-referential representations in S4

2011-04-20 Thread John Chambers
The warning is there because all is not "just fine", in general and in 
particular not in your example.


If a superclass is not virtual, the prototype object for the new class 
must have a member of that class in the appropriate slot.  How could it 
do so in this case?  As a result, your class will return an invalid 
object from a call to new().


So one might argue that the current rules are too lax, and this should 
be an error.


The fundamental point is that S4 classes, as opposed to the new 
reference classes, don't deal in "references", self- or other.


Ways to deal with such recursive structures are discussed in section 9.7 
of Software for Data Analysis.


One version of what you were perhaps trying to do might, for a binary 
tree, be:


> setClassUnion("MyNode", c("NULL", "vector"))
[1] "MyNode"
>
> setClass("FullNode", representation(left = "MyNode", right ="MyNode",
+   parent = "MyNode"))
[1] "FullNode"
> setIs("FullNode", "MyNode")

Nodes can be full, a vector as a leaf, or empty.

John

On 4/19/11 3:10 PM, James Bullard wrote:


I'm trying to do the following:


setClass("MyNode", representation(parent = "MyNode"))

[1] "MyNode"
Warning message:
undefined slot classes in definition of "MyNode": parent(class "MyNode")

I scanned the docs, but found nothing. The representation function has no
problem, it's the setClass function which gives the warning.

What I'm trying to understand is why have the warning - it seems to work
just fine when I instantiate the class. Can we add an argument to the
setClass to suppress the warning?

This question was asked previously, but not answered in any satisfactory way:

http://r.789695.n4.nabble.com/Linked-List-in-R-td3303021.html

thanks, jim




R version 2.12.2 Patched (2011-03-09 r54717)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=C  LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
  [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

other attached packages:
[1] h5r_1.1

loaded via a namespace (and not attached):
[1] tools_2.12.2

__
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] Sweave tokens not in column 1: enhancement request

2011-04-20 Thread Friedrich Leisch
> 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
  > <>
  > do something-else
  > }

  > Sweave will say that << is an error. Would it be difficult to change Sweave
  > so that formatting in the conventional way becomes possible? I'm thinking
  > both of the .Rnw file and of the final output in the .pdf or .ps file.

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.

Best,
Fritz

__
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-20 Thread Sharpie

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.



Karl-Dieter Crisman wrote:
> 
> 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.

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.



Karl-Dieter Crisman wrote:
> 
> 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?
> 
> 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
> 


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.

In the ask.sagemath question the