[Rd] S4 objects in data frames?

2007-09-19 Thread Byron Ellis
Is there any way to get S4 objects into a data frame and have the
resulting data frame actually be printable?

After a good deal of work I managed to convert an S4 objects that
holds several other objects into a data.frame object using a custom
as.data.frame method, but I have been unable to discover how to make
the result data.frame printable.

I've tried making format() generic, no dice. It eventually just
wanders down the path to filter.default, which then tries to
(incorrectly) unlist the contained S4 object. Obviously this doesn't
work.

I can make a matrix of these objects without much trouble (there isn't
a reasonable print function there either, but at least it doesn't
error out).

Any clues? Someone who's managed to pull it off? I'm ready to do
something horrible like create a wrapper class that extends character
just to get it to work right, but this will be annoying for other
reasons.

-- 
Byron Ellis ([EMAIL PROTECTED])
"Oook" -- The Librarian

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


Re: [Rd] packages MANOR, qvalue, and tkWidgets fail install on Fedora 7 with latest R-beta build

2007-09-19 Thread Martin Morgan
Hi Mark --

sessionInfo and the warning messages are not enough here. Try to
install one of the failing packages and provide the complete
transcript of the process.

Consider sending this to the Bioconductor mailing lists (bioc-devel,
in particular, since these packages are in the development branch).

Martin

Mark W Kimpel <[EMAIL PROTECTED]> writes:

> Had some packages fail install so I updated to today's R-beta release. 
> On updating packages the following packages still fail. sessionInfo 
> follows. Mark
>
> Warning messages:
> 1: In install.packages(update[instlib == l, "Package"], l, contriburl = 
> contriburl,  :
>installation of package 'MANOR' had non-zero exit status
> 2: In install.packages(update[instlib == l, "Package"], l, contriburl = 
> contriburl,  :
>installation of package 'qvalue' had non-zero exit status
> 3: In install.packages(update[instlib == l, "Package"], l, contriburl = 
> contriburl,  :
>installation of package 'tkWidgets' had non-zero exit status
>  > sessionInfo()
> R version 2.6.0 beta (2007-09-18 r42895)
> i686-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] tools stats graphics  grDevices utils datasets  methods
> [8] base
>
> other attached packages:
> [1] limma_2.11.13  affy_1.15.9preprocessCore_0.99.18
> [4] affyio_1.5.11  Biobase_1.15.33graph_1.15.20
>
> loaded via a namespace (and not attached):
> [1] cluster_1.11.8  rcompgen_0.1-15
> -- 
>
> ---
>
> Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
> Indiana University School of Medicine
>
> 15032 Hunter Court, Westfield, IN  46074
>
> (317) 490-5129 Work, & Mobile & VoiceMail
> (317) 663-0513 Home (no voice mail please)
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

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


[Rd] packages MANOR, qvalue, and tkWidgets fail install on Fedora 7 with latest R-beta build

2007-09-19 Thread Mark W Kimpel
Had some packages fail install so I updated to today's R-beta release. 
On updating packages the following packages still fail. sessionInfo 
follows. Mark

Warning messages:
1: In install.packages(update[instlib == l, "Package"], l, contriburl = 
contriburl,  :
   installation of package 'MANOR' had non-zero exit status
2: In install.packages(update[instlib == l, "Package"], l, contriburl = 
contriburl,  :
   installation of package 'qvalue' had non-zero exit status
3: In install.packages(update[instlib == l, "Package"], l, contriburl = 
contriburl,  :
   installation of package 'tkWidgets' had non-zero exit status
 > sessionInfo()
R version 2.6.0 beta (2007-09-18 r42895)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] limma_2.11.13  affy_1.15.9preprocessCore_0.99.18
[4] affyio_1.5.11  Biobase_1.15.33graph_1.15.20

loaded via a namespace (and not attached):
[1] cluster_1.11.8  rcompgen_0.1-15
-- 

---

Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
Indiana University School of Medicine

15032 Hunter Court, Westfield, IN  46074

(317) 490-5129 Work, & Mobile & VoiceMail
(317) 663-0513 Home (no voice mail please)

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


Re: [Rd] Sweave vignettes and bitmap on windows

2007-09-19 Thread tshort

While I don't agree with it, this "feature" of bitmap is deliberate according
to Prof. Ripley:

http://tolstoy.newcastle.edu.au/R/devel/04/09/0682.html

- Tom

Tom Short
EPRI


Martin Morgan wrote:
> 
> During vignette generation on Windows, Sweave seems to clean up before
> all graphics files are completely processed. For instance, if tmp.Rnw
> is:
> 
> \documentclass[12pt]{article}
> \begin{document}
> <<>>=
> bitmap("afile.png")
> plot(1:100)
> dev.off()
> @ 
> \end{document}
> 
> Then:
> 
> C:\R\tmp>R CMD Sweave tmp.Rnw
> Writing to file tmp.tex
> Processing code chunks ...
>  1 : echo term verbatim
> 
> You can now run LaTeX on 'tmp.tex'
> 
> C:\R\tmp>Error: /undefinedfilename in
> (C:\\DOCUME~1\\mtmorgan\\LOCALS~1\\Temp\\R
> Operand stack:
> 
> Execution stack:
>%interp_exit   .runexec2   --nostringval--   --nostringval--  
> --nostringval-
>   --nostringval--   --nostringval--   false   1   %stopped_push
> Dictionary stack:
>--dict:1126/1686(ro)(G)--   --dict:0/20(G)--   --dict:70/200(L)--
> Current allocation mode is local
> Last OS error: No such file or directory
> AFPL Ghostscript 8.54: Unrecoverable error, exit code 1
> 
> Note Sweave finishes before the error message appears.  Adding
> Sys.sleep(10) appears to give ghostscript a chance to finish, and no
> error message is generated.
> 
> Are there solutions to this?
> 
> C:\R\tmp>R --version
> R version 2.6.0 alpha (2007-09-05 r42789)
> Copyright (C) 2007 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
> 
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under the terms of the
> GNU General Public License version 2.
> For more information about these matters see
> http://www.gnu.org/licenses/.
> 
> Thanks,
> -- 
> Martin Morgan
> Bioconductor / Computational Biology
> http://bioconductor.org
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Sweave-vignettes-and-bitmap-on-windows-tf4484568.html#a12789148
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] Sweave vignettes and bitmap on windows

2007-09-19 Thread Martin Morgan
During vignette generation on Windows, Sweave seems to clean up before
all graphics files are completely processed. For instance, if tmp.Rnw
is:

\documentclass[12pt]{article}
\begin{document}
<<>>=
bitmap("afile.png")
plot(1:100)
dev.off()
@ 
\end{document}

Then:

C:\R\tmp>R CMD Sweave tmp.Rnw
Writing to file tmp.tex
Processing code chunks ...
 1 : echo term verbatim

You can now run LaTeX on 'tmp.tex'

C:\R\tmp>Error: /undefinedfilename in (C:\\DOCUME~1\\mtmorgan\\LOCALS~1\\Temp\\R
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
  --nostringval--   --nostringval--   false   1   %stopped_push
Dictionary stack:
   --dict:1126/1686(ro)(G)--   --dict:0/20(G)--   --dict:70/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
AFPL Ghostscript 8.54: Unrecoverable error, exit code 1

Note Sweave finishes before the error message appears.  Adding
Sys.sleep(10) appears to give ghostscript a chance to finish, and no
error message is generated.

Are there solutions to this?

C:\R\tmp>R --version
R version 2.6.0 alpha (2007-09-05 r42789)
Copyright (C) 2007 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License version 2.
For more information about these matters see
http://www.gnu.org/licenses/.

Thanks,
-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

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


[Rd] copying promise

2007-09-19 Thread Gabor Grothendieck
1. Is there some way to copy a promise so that the copy has the same
expression in its promise as the original.  In the following we
y is a promise that we want to copy to z.  We
want z to be a promise based on the expression x since y is a
promise based on the expression x.  Thus the answer to the code
below is desired to be z=2 but its 1, 1 and y in the next three
examples so they are not the answer. See examples at end.

2. Is there some way to determine if a variable holds a promise
without evaluating it?

This code relates to question 1.

# example 1
x <- 0
delayedAssign("y", x)
x <- 1
# this forces y which is not what we want
z <- y
x <- 2
z # 1

# example 2
# this connects to z to x via y which is not what we want
#  since if y is forced then z takes its value from that, not x
x <- 0
delayedAssign("y", x)
delayedAssign("z", y)
x <- 1
y
x <- 2
z # 1

# example 3
# this attempts to assign the expression underlying promise y to z
# which seems closest in spirit to what we want
# but it does not work as intended
x <- 0
delayedAssign("y", x)
delayedAssign("z", substitute(y))
x <- 1
y
x <- 2
z # y

> R.version.string # Vista
[1] "R version 2.6.0 alpha (2007-09-06 r42791)"

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


Re: [Rd] delayedAssign

2007-09-19 Thread Gabor Grothendieck
Also note that earlier in the same example we have:

> msg <- "old"
> delayedAssign("x", msg)
> msg <- "new!"
> x #- new!
[1] "new!"
> substitute(x) #- msg
x
> R.version.string # Vista
[1] "R version 2.6.0 alpha (2007-09-06 r42791)"

That is substitute(x) gives x, not msg.

On 9/19/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> The last two lines of example(delayedAssign) give this:
>
> > e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2})
> > (le <- as.list(e)) # evaluates the promises
> $x
> 
> $y
> 
> $z
> 
>
> which contrary to the comment appears unevaluated.  Is the comment
> wrong or is it supposed to return an evaluated result but doesn't?
>
> > R.version.string # Vista
> [1] "R version 2.6.0 alpha (2007-09-06 r42791)"
>

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


Re: [Rd] delayedAssign

2007-09-19 Thread Peter Dalgaard
Gabor Grothendieck wrote:
> The last two lines of example(delayedAssign) give this:
>
>   
>> e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2})
>> (le <- as.list(e)) # evaluates the promises
>> 
> $x
> 
> $y
> 
> $z
> 
>
> which contrary to the comment appears unevaluated.  Is the comment
> wrong or is it supposed to return an evaluated result but doesn't?
>
>   
My guess would be that the behaviour is unintended. It should be harder 
than that to get promises visible at the user level. Luke?

>> R.version.string # Vista
>> 
> [1] "R version 2.6.0 alpha (2007-09-06 r42791)"
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>   


-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

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


Re: [Rd] How to test if R is running on a Mac

2007-09-19 Thread Hin-Tak Leung
On linux boxes,
   version$os and R.version$os
is 'linux-gnu'. I assume that it would be 'darwin-apple' on
Mac's?

Henrik Bengtsson wrote:
> isApple <- function(...) {
>   isApple <- FALSE;
>   tryCatch({
> ans <- readline("Do you see an Apple key on the keyboard you are
> typing on? yes/no");
> isApple <- (ans == "yes");
>   }, mouseClick = function(ex) {
> isApple <<- TRUE;
>   })
> }
> 
> /H
> 
> 
> On 9/19/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>> On 9/19/2007 9:41 AM, Gorjanc Gregor wrote:
>>> Hi!
>>>
>>> Is there any way to test if R is running on a Mac? I usually use
>>> value of .Platform$OS.type for windows or unix, but Mac falls in the
>>> latter group.
>> Remember to also look at .Platform$GUI:  the GUI version behaves quite
>> differently from command line R from a user's point of view (both on the
>> Mac and on Windows), and occasionally from a programmer's point of view
>> (e.g. the graphics device on the Mac).
>>
>> Duncan
>>
>> __
>> 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

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


Re: [Rd] How to test if R is running on a Mac

2007-09-19 Thread Henrik Bengtsson
isApple <- function(...) {
  isApple <- FALSE;
  tryCatch({
ans <- readline("Do you see an Apple key on the keyboard you are
typing on? yes/no");
isApple <- (ans == "yes");
  }, mouseClick = function(ex) {
isApple <<- TRUE;
  })
}

/H


On 9/19/07, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
> On 9/19/2007 9:41 AM, Gorjanc Gregor wrote:
> > Hi!
> >
> > Is there any way to test if R is running on a Mac? I usually use
> > value of .Platform$OS.type for windows or unix, but Mac falls in the
> > latter group.
>
> Remember to also look at .Platform$GUI:  the GUI version behaves quite
> differently from command line R from a user's point of view (both on the
> Mac and on Windows), and occasionally from a programmer's point of view
> (e.g. the graphics device on the Mac).
>
> Duncan
>
> __
> 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] R-2.6.0 for Windows, semi-transparent colours and layout()

2007-09-19 Thread Henric Nilsson (Private)
Prof Ripley,

Quoting Prof Brian Ripley <[EMAIL PROTECTED]>:

> On Sat, 15 Sep 2007, Henric Nilsson (Public) wrote:
>
>> Hi,
>>
>> The added support for semi-transparent colours in `windows' under
>> R-2.6.0 for Windows is much appreciated.
>>
>> However, I've discovered that issuing a `layout' (or `par' with
>> arguments `mfcol'/`mfrow') call and then trying to plot several figures
>> with semi-transparent colour on the same page results in only the first
>> one being fully drawn. E.g.
>
> That's not the whole story, as my test examples using multiple subplots
> did work.
>
> The problem I found is that clipping rectangles were being used in some
> places where I cannot find documentation that they should be.
> So explicitly setting the clipping rectangle before each alpha-blending
> call seems to fix the problematic examples, including yours.

Many thanks for looking into and fixing this -- I really appreciate it!


Henric



>>
>>> x <- rnorm(1)
>>> y <- rnorm(1)
>>>
>>> layout(matrix(1:2, ncol = 2))
>>> plot(y ~ x, pch = 16, col = rgb(1, 0, 0, 0.15))
>>> plot(y ~ x, pch = 16, col = rgb(1, 0, 0, 0.15))
>>
>> results in the second one having only the axes and box, but no data
>> points. This is under
>>
>>> sessionInfo()
>> R version 2.6.0 alpha (2007-09-14 r42843)
>> i386-pc-mingw32
>>
>> locale:
>> LC_COLLATE=Swedish_Sweden.1252;LC_CTYPE=Swedish_Sweden.1252;LC_MONETARY=Swedish_Sweden.1252;LC_NUMERIC=C;LC_TIME=Swedish_Sweden.1252
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>>
>> Henric
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> -- 
> Brian D. Ripley,  [EMAIL PROTECTED]
> 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] Best practices - R CMD check and vignettes

2007-09-19 Thread James W. MacDonald
Thanks, Max. Right after sending that email I was frantically searching 
for the 'Retract' button on my mailer, but evidently there isn't one ;-D.

Anyway, I'm not sure the entire package is installed during either R CMD 
build or R CMD check, so I am not sure that will work. My ill-advised 
idea of hard-coding the path won't work either, since the path will be 
different for these two steps.

However, the obvious fix that occurred to me 1 nanosecond after hitting 
'send' was that the saved objects should just be in the /inst/doc 
directory with the .Rnw files instead of being in some other directory. 
Originally I had the raw data in the /examples directory so users of my 
package could practice using those data, but really I think the only use 
is for building the vignettes, so moving to /inst/doc appears the most 
reasonable course of action.

Best,

Jim



Kuhn, Max wrote:
> Jim,
> 
> But I'm not sure if this works if the package has not been installed (or
> it might find a version already installed in your library path), but
> give it a try:
> 
>load(system.file("examples", "somedata.Rdata", package = "PkgName"))
> 
> Max 
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of James MacDonald
> Sent: Monday, September 17, 2007 11:07 PM
> To: [EMAIL PROTECTED]
> Subject: [Rd] Best practices - R CMD check and vignettes
> 
> Hi,
> 
> I have a package that contains two vignettes that both use saved objects
> 
> in the examples directory of the package. With previous versions of R I 
> could have a code chunk in the vignette like this:
> 
> <>=
> load("../examples/somedata.Rdata")
> @
> 
> followed by a code chunk like
> 
> <>=
> foo <- bar("data")
> @
> 
> that simulated the actual reading in of the data (I use a saved object 
> to limit package size).
> 
> This passed check with previous versions of R, but under R-2.6.0alpha, 
> the vignettes are dumped into an inst directory in the .Rcheck 
> directory, where Sweave() and texi2dvi() are run. Unfortunately, the 
> above code chunks no longer work.
> 
> I can certainly hard code the first chunk to find the .Rdata file, but I
> 
> have to imagine there is a much more elegant way to do this.
> 
> Any suggestions?
> 
> Best,
> 
> Jim
> 
> 

-- 
James W. MacDonald, M.S.
Biostatistician
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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


Re: [Rd] building a package - shared library loading problem

2007-09-19 Thread Simon Urbanek
Konrad,

for a package you should not be using R CMD SHLIB at all. It is used  
internally and for non-package compilation.

If you have a proper source package, you just install it using R CMD  
INSTALL.

To be precise, assuming you have your package and source code in the  
"foo" directory you can create the source package like this:

tar fcz foo_1.0.tar.gz foo

That package doesn't contain any .so objects and thus can be  
installed anywhere using

R CMD INSTALL foo_1.0.tar.gz

That step will create the .so in the appropriate place which differs  
by system and R version. If you want to create a binary package for a  
given platform, use the --build flag.

Please read 'Writing R Extensions' - you just want to use the src  
directory and not mess with libs.

Cheers,
Simon


On Sep 19, 2007, at 1:25 PM, Konrad Smolinski wrote:

> Dear All,
> I am trying to write my first R package and I bump into loading shared
> library problem( working on Mac OS X 10.4.10 as well as Linux Ubuntu).
> I want to makes use of (incorporate) a shared library  
> matchinglib.so in
> the package. Library was created via R CMD -SHLIB.
> Following 'Writing R Extensions' I place matchinglib.so in the 'libs'
> directory and use NAMESPACE file with an entry:
> useDynLib(matchinglib)
>
> Now, executing 'R CMD check mypackage' I face the following error  
> on OS X:
> -
> * checking whether the package can be loaded ... ERROR
> Error in library.dynam(lib, package, package.lib) :
>  shared library 'matchinglib' not found
> Error: package/namespace load failed for 'cheetah'
> Execution halted
>
> It looks like this package has a loading problem: see the messages for
> details.
> 
> The same problem occurs under Linux.
>
> Shall I specify a direct path to libs or modify NAMESPACE?
>
> konrad
> ---
> Konrad Smolinski
> Economics Department
> European University Institute
> Badia Fiesolana
> Via dei Roccettini 9
> I-50014 San Domenico di Fiesole (FI)
> ITALY
>
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

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


[Rd] delayedAssign

2007-09-19 Thread Gabor Grothendieck
The last two lines of example(delayedAssign) give this:

> e <- (function(x, y = 1, z) environment())(1+2, "y", {cat(" HO! "); pi+2})
> (le <- as.list(e)) # evaluates the promises
$x

$y

$z


which contrary to the comment appears unevaluated.  Is the comment
wrong or is it supposed to return an evaluated result but doesn't?

> R.version.string # Vista
[1] "R version 2.6.0 alpha (2007-09-06 r42791)"

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


Re: [Rd] Best practices - R CMD check and vignettes

2007-09-19 Thread Kuhn, Max
Jim,

But I'm not sure if this works if the package has not been installed (or
it might find a version already installed in your library path), but
give it a try:

   load(system.file("examples", "somedata.Rdata", package = "PkgName"))

Max 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of James MacDonald
Sent: Monday, September 17, 2007 11:07 PM
To: [EMAIL PROTECTED]
Subject: [Rd] Best practices - R CMD check and vignettes

Hi,

I have a package that contains two vignettes that both use saved objects

in the examples directory of the package. With previous versions of R I 
could have a code chunk in the vignette like this:

<>=
load("../examples/somedata.Rdata")
@

followed by a code chunk like

<>=
foo <- bar("data")
@

that simulated the actual reading in of the data (I use a saved object 
to limit package size).

This passed check with previous versions of R, but under R-2.6.0alpha, 
the vignettes are dumped into an inst directory in the .Rcheck 
directory, where Sweave() and texi2dvi() are run. Unfortunately, the 
above code chunks no longer work.

I can certainly hard code the first chunk to find the .Rdata file, but I

have to imagine there is a much more elegant way to do this.

Any suggestions?

Best,

Jim


-- 
James W. MacDonald, MS
Biostatistician
UMCCC cDNA and Affymetrix Core
University of Michigan
1500 E Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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

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


[Rd] Best practices - R CMD check and vignettes

2007-09-19 Thread James MacDonald
Hi,

I have a package that contains two vignettes that both use saved objects 
in the examples directory of the package. With previous versions of R I 
could have a code chunk in the vignette like this:

<>=
load("../examples/somedata.Rdata")
@

followed by a code chunk like

<>=
foo <- bar("data")
@

that simulated the actual reading in of the data (I use a saved object 
to limit package size).

This passed check with previous versions of R, but under R-2.6.0alpha, 
the vignettes are dumped into an inst directory in the .Rcheck 
directory, where Sweave() and texi2dvi() are run. Unfortunately, the 
above code chunks no longer work.

I can certainly hard code the first chunk to find the .Rdata file, but I 
have to imagine there is a much more elegant way to do this.

Any suggestions?

Best,

Jim


-- 
James W. MacDonald, MS
Biostatistician
UMCCC cDNA and Affymetrix Core
University of Michigan
1500 E Medical Center Drive
7410 CCGC
Ann Arbor MI 48109
734-647-5623

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


[Rd] building a package - shared library loading problem

2007-09-19 Thread Konrad Smolinski
Dear All,
I am trying to write my first R package and I bump into loading shared  
library problem( working on Mac OS X 10.4.10 as well as Linux Ubuntu).
I want to makes use of (incorporate) a shared library matchinglib.so in  
the package. Library was created via R CMD -SHLIB.
Following 'Writing R Extensions' I place matchinglib.so in the 'libs'  
directory and use NAMESPACE file with an entry:
useDynLib(matchinglib)

Now, executing 'R CMD check mypackage' I face the following error on OS X:
-
* checking whether the package can be loaded ... ERROR
Error in library.dynam(lib, package, package.lib) :
 shared library 'matchinglib' not found
Error: package/namespace load failed for 'cheetah'
Execution halted

It looks like this package has a loading problem: see the messages for
details.

The same problem occurs under Linux.

Shall I specify a direct path to libs or modify NAMESPACE?

konrad
---
Konrad Smolinski
Economics Department
European University Institute
Badia Fiesolana
Via dei Roccettini 9
I-50014 San Domenico di Fiesole (FI)
ITALY

[EMAIL PROTECTED]
[EMAIL PROTECTED]

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


Re: [Rd] How to test if R is running on a Mac

2007-09-19 Thread Duncan Murdoch
On 9/19/2007 9:41 AM, Gorjanc Gregor wrote:
> Hi!
> 
> Is there any way to test if R is running on a Mac? I usually use
> value of .Platform$OS.type for windows or unix, but Mac falls in the
> latter group.

Remember to also look at .Platform$GUI:  the GUI version behaves quite 
differently from command line R from a user's point of view (both on the 
Mac and on Windows), and occasionally from a programmer's point of view 
(e.g. the graphics device on the Mac).

Duncan

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


Re: [Rd] How to test if R is running on a Mac

2007-09-19 Thread Vladimir Eremeev



Vladimir Eremeev wrote:
> 
> 
> Gregor Gorjanc-2 wrote:
>> 
>> Hi!
>> 
>> Is there any way to test if R is running on a Mac? I usually use
>> value of .Platform$OS.type for windows or unix, but Mac falls in the
>> latter group.
>> 
>> Thanks, Gregor
>> 
> 
> What is in .Platform$path.sep?
> Windows has ";", unix has ":".
> Mac?
> 
And what is in .Platform$file.sep?
-- 
View this message in context: 
http://www.nabble.com/How-to-test-if-R-is-running-on-a-Mac-tf4481121.html#a12778683
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 test if R is running on a Mac

2007-09-19 Thread Vladimir Eremeev


Gregor Gorjanc-2 wrote:
> 
> Hi!
> 
> Is there any way to test if R is running on a Mac? I usually use
> value of .Platform$OS.type for windows or unix, but Mac falls in the
> latter group.
> 
> Thanks, Gregor
> 

What is in .Platform$path.sep?
Windows has ";", unix has ":".
Mac?
-- 
View this message in context: 
http://www.nabble.com/How-to-test-if-R-is-running-on-a-Mac-tf4481121.html#a12778663
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 test if R is running on a Mac

2007-09-19 Thread Oleg Sklyar
I had the same problem. The following line using either 'apple' or
'darwin' does the job for me (tested on many different Macs):

length(grep("apple", tolower(Sys.getenv("R_PLATFORM" != 0



On Wed, 2007-09-19 at 15:41 +0200, Gorjanc Gregor wrote:
> Hi!
> 
> Is there any way to test if R is running on a Mac? I usually use
> value of .Platform$OS.type for windows or unix, but Mac falls in the
> latter group.
> 
> Thanks, Gregor
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
-- 
Dr Oleg Sklyar * EBI-EMBL, Cambridge CB10 1SD, UK * +44-1223-494466

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


[Rd] How to test if R is running on a Mac

2007-09-19 Thread Gorjanc Gregor
Hi!

Is there any way to test if R is running on a Mac? I usually use
value of .Platform$OS.type for windows or unix, but Mac falls in the
latter group.

Thanks, Gregor

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


Re: [Rd] chartr better

2007-09-19 Thread Prof Brian Ripley
Thank you for this.

Unfortunately qsort and bsearch are C99 functions, and I don't think we 
can safely assume that they are present.  So I am going to put this into 
R-devel but not 2.6.0.  When we have a bit more experience we can consider 
backporting it to 2.6.1 (I don't want to change the autoconf stuff at this 
stage).

Brian Ripley

On Thu, 13 Sep 2007, Ei-ji Nakama wrote:

> For example, the following changes are necessary when i convert a
> Japanese hiragana into katakana in chattr.
>
> R code:
>> chartr("\u3041-\u3093","\u30a1-\u30f3","\u3084\u3063\u305f\u30fc")
>
> --- R-alpha.orig/src/main/character.c   2007-09-05 07:13:27.0 +0900
> +++ R-alpha/src/main/character.c2007-09-13 16:10:21.0 +0900
> @@ -2041,6 +2041,16 @@
> return(c);
> }
>
> +typedef struct { wchar_t c_old, c_new; } xtable_t;
> +static inline int xtable_comp(const xtable_t *a, const xtable_t *b)
> +{
> +return a->c_old - b->c_old;
> +}
> +static inline int xtable_key_comp(const wchar_t *a, const xtable_t *b)
> +{
> +return *a - b->c_old;
> +}
> +
> SEXP attribute_hidden do_chartr(SEXP call, SEXP op, SEXP args, SEXP env)
> {
> SEXP old, _new, x, y;
> @@ -2064,14 +2074,18 @@
> #ifdef SUPPORT_MBCS
> if(mbcslocale) {
> int j, nb, nc;
> -wchar_t xtable[65536 + 1], c_old, c_new, *wc;
> +xtable_t *xtable;
> +int   xtable_cnt;
> +wchar_t c_old, c_new, *wc;
> const char *xi, *s;
> struct wtr_spec *trs_old, **trs_old_ptr;
> struct wtr_spec *trs_new, **trs_new_ptr;
> -
> -for(i = 0; i <= UCHAR_MAX; i++) xtable[i] = i;
> +struct wtr_spec *trs_cnt, **trs_cnt_ptr;
>
> /* Initialize the old and new wtr_spec lists. */
> +trs_cnt = Calloc(1, struct wtr_spec);
> +trs_cnt->type = WTR_INIT;
> +trs_cnt->next = NULL;
> trs_old = Calloc(1, struct wtr_spec);
> trs_old->type = WTR_INIT;
> trs_old->next = NULL;
> @@ -2084,6 +2098,7 @@
> if(nc < 0) error(_("invalid multibyte string 'old'"));
> wc = (wchar_t *) R_AllocStringBuffer((nc+1)*sizeof(wchar_t), &cbuff);
> mbstowcs(wc, s, nc + 1);
> +wtr_build_spec(wc, trs_cnt); /* use count only */
> wtr_build_spec(wc, trs_old);
>
>s = translateChar(STRING_ELT(_new, 0));
> @@ -2096,38 +2111,54 @@
> /* Initialize the pointers for walking through the old and new
>wtr_spec lists and retrieving the next chars from the lists.
> */
> +trs_cnt_ptr = Calloc(1, struct wtr_spec *);
> +*trs_cnt_ptr = trs_cnt->next;
> +   for( xtable_cnt = 0 ; wtr_get_next_char_from_spec(trs_cnt_ptr)
> ;xtable_cnt++ );
> +   Free(trs_cnt_ptr);
> +   xtable = (xtable_t *)R_alloc(xtable_cnt+1,sizeof(xtable_t));
> +
> trs_old_ptr = Calloc(1, struct wtr_spec *);
> *trs_old_ptr = trs_old->next;
> trs_new_ptr = Calloc(1, struct wtr_spec *);
> *trs_new_ptr = trs_new->next;
> -for(;;) {
> +for(i=0;;i++) {
> c_old = wtr_get_next_char_from_spec(trs_old_ptr);
> c_new = wtr_get_next_char_from_spec(trs_new_ptr);
> if(c_old == '\0')
> break;
> else if(c_new == '\0')
> error(_("'old' is longer than 'new'"));
> -else
> -xtable[c_old] = c_new;
> +else{
> +xtable[i].c_old=c_old;
> +xtable[i].c_new=c_new;
> +   }
> }
> +
> /* Free the memory occupied by the wtr_spec lists. */
> wtr_free_spec(trs_old);
> wtr_free_spec(trs_new);
> Free(trs_old_ptr); Free(trs_new_ptr);
>
> +qsort(xtable, xtable_cnt, sizeof(xtable_t),
> +  (int(*)(const void *, const void *))xtable_comp);
> +
> n = LENGTH(x);
> PROTECT(y = allocVector(STRSXP, n));
> for(i = 0; i < n; i++) {
> if (STRING_ELT(x,i) == NA_STRING)
> SET_STRING_ELT(y, i, NA_STRING);
> else {
> +xtable_t *tbl;
> xi = translateChar(STRING_ELT(x, i));
> nc = mbstowcs(NULL, xi, 0);
> if(nc < 0)
> error(_("invalid input multibyte string %d"), i+1);
> wc = (wchar_t *)
> R_AllocStringBuffer((nc+1)*sizeof(wchar_t), &cbuff);
> mbstowcs(wc, xi, nc + 1);
> -for(j = 0; j < nc; j++) wc[j] = xtable[wc[j]];
> +for(j = 0; j < nc; j++)
> +if (tbl = bsearch(&wc[j], xtable, xtable_cnt,
> sizeof(xtable_t),
> +  (int(*)(const void *, const
> void *))xtable_key_comp))
> +wc[j]=tbl->c_new;
> nb = wcstombs(NULL, wc, 0);
> cbuf = CallocCharBuf(nb);
> wcstombs(cbuf, wc, nb + 1);
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics