Re: [Rd] R package Matrix failing to build with R-devel on Ubuntu AMD64

2008-01-31 Thread Martin Maechler
 MWK == Mark W Kimpel [EMAIL PROTECTED]
 on Tue, 29 Jan 2008 23:14:30 -0500 writes:

MWK Switched back to R-devel tonight after using R-2.6.1 for awhile and 
when 
MWK I updated my devel packages Matrix installation failed. Not critical 
for 
MWK me but thought I should report it. I am using Ubuntu Gusty AMD64 OS. 
MWK Tail of install output and sessionInfo follows. Mark

MWK Loading required package: methods
MWK Loading required package: lattice

MWK Attaching package: 'Matrix'


MWK The following object(s) are masked from package:stats :

MWK xtabs

MWK Error in new(dgCMatrix) :
MWK trying to generate an object from a virtual class (dgCMatrix)
   

MWK Calls: Anonymous ... eval.parent - eval - eval - eval - eval - 
MWK new - .Call
MWK Execution halted
MWK ERROR: installing package indices failed
 
MWK ** Removing '/home/mkimpel/R_HOME/site-library/Matrix'
MWK ** Restoring previous '/home/mkimpel/R_HOME/site-library/Matrix'

MWK The downloaded packages are in
MWK /tmp/RtmpJviXfF/downloaded_packages
MWK Warning message:
MWK In install.packages(Matrix) :
MWK installation of package 'Matrix' had non-zero exit status
 sessionInfo()
MWK R version 2.7.0 Under development (unstable) (2008-01-29 r44238)
MWK x86_64-unknown-linux-gnu

Thank you, Mark, for the report.

Indeed --- to my own very big astonishment --- 
I *can* reproduce the problem.

In the above messages, it's pretty funny that
dgCMatrix is said to be a virtual class (which it is clearly
not from the Matrix source).

The daily CRAN package checks don't show the problem yet,
but the checks' R version is

  R 2.7.0 Under development (unstable) (2008-01-27 r44199)

which is a bit older, than the one you used 
(and even older than the one I used . r44258)

I'm pretty sure I know around where the problem appeared..
More on this later.

Martin Maechler, ETH Zurich

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


Re: [Rd] Documentation of the dev.copy2eps function. (PR#10656)

2008-01-31 Thread Clément Raievsky
Thanks for replying.

On Jan 30, 2008 2:28 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Tue, 29 Jan 2008, [EMAIL PROTECTED] wrote:

 
  The documentation of the dev.copy2eps() function should mention the file
  option which set the output file name

 Current R says

   ...: Arguments to the 'device' function above. For 'dev.print',
this includes 'which' and by default any 'postscript'
arguments.

In my humble opinion, in the sentence Arguments to the 'device'
function above, it is not clear to what the 'device' function above
refers because 'device' is an argument in the text above this
sentence.
Therefore, I think it's difficult to understand which are the possible
arguments for the copy2eps function.


   For 'dev.copy2eps', 'width' and 'height' are taken from the
   current device unless otherwise specified.  If just one of 'width'
   and 'height' is specified, the other is adjusted to preserve the
   aspect ratio of the device being copied.  The default file name is
   'Rplot.eps'.

 I'm not sure why 'file' is more important than any other argument
 mentioned in ..., but we do say what the default is (because it is
 different).  Can you tell us what more we 'should' say in your opinion,
 and why?

I mentioned the 'file' argument because it was the one which I was
looking for while reading the doc.
Maybe all arguments valid for the postscript device are allowed for
the copy2eps function but it is still not clear to me.

Best regards,

Clément.

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


Re: [Rd] [rfc] Package to access the internal zlib library.

2008-01-31 Thread jason
And Duncan Temple Lang writes:
 This deals with various compression schemes and does things in
 memory.  Hopefully there isn't much overlap and the two might
 be complementary.

Rcompression provides what's necessary for R.matlab's readMat.
I'll switch to using it instead.  What would it take to move
Rcompression into CRAN?

Jason

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


Re: [Rd] The standalone Rmath library and VC++ 2003

2008-01-31 Thread Oran Johnson
Yes, I used Rtools to compile the standalone Rmath library. However,
C:\Rtools\MinGW\lib\libm.a does not contain log1p;
C:\Rtools\MinGW\lib\libmingwex.a does. Once I replaced libm.a with
libmingwex.a, the application linked successfully and the following test
program was successful:

#include iostream
#define MATHLIB_STANDALONE
#include Rmath.h

int main()
{
double d = dbeta(0.5, 2.0, 3.0, 1); 
double q = qbeta(0.5, 2.0, 3.0, 1, 0); 
double p = pbeta(0.5, 2.0, 3.0, 1, 0); 
double r = rbeta(0.5, 2.0);

std::cout  dbeta =   d  \n;
std::cout  qbeta =   q  \n; 
std::cout  pbeta =   p  \n;
std::cout  rbeta =   r  \n; 
}


dbeta = 0.405465
qbeta = 0.385728
pbeta = 0.6875
rbeta = 0.422286
Press any key to continue

Thanks
Oran

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 30, 2008 1:06 PM
To: Oran Johnson
Cc: r-devel@r-project.org
Subject: Re: [Rd] The standalone Rmath library and VC++ 2003

On Tue, 29 Jan 2008, Oran Johnson wrote:

 Linking my VC++ application with the standalone Rmath library yields
the
 following;

Looks like you compiled the standalone Rmath library with MinGW.  You 
can't expect to mix-and-match compilers and link together a static
library 
built under another compiler.

It is possible that this will work if you try linking to Rmath.dll: 
WIndows' DLLs are fairly portable (although parameter passing
conventions 
do differ, and we know 'double complex' is not portable).  I assume you 
know how to make a VC++ import library from a DLL, which you would need
to 
do.

If you compiled standalone Rmath under VC++, you would not have got a .a

but a lib, at least by default.  You are welcome to try that: it has
been 
done in the past but is not something we support (nor even would want to

answer questions about).


 -- Build started: Project: Complex plugin, Configuration: Debug
 Win32 --



 Linking...

   Creating library .\../Debug/complex_plugin.lib and object
 .\../Debug/complex_plugin.exp

 libRmath.a(mlutils.o) : warning LNK4217: locally defined symbol __iob
 imported in function _REprintf

 libRmath.a(dbeta.o) : error LNK2019: unresolved external symbol _log1p
 referenced in function _dbeta

 libRmath.a(qbeta.o) : error LNK2019: unresolved external symbol _log1p
 referenced in function _qbeta

 libRmath.a(lbeta.o) : error LNK2019: unresolved external symbol _log1p
 referenced in function _lbeta

 libRmath.a(toms708.o) : error LNK2001: unresolved external symbol
_log1p

 libRmath.a(qbeta.o) : error LNK2019: unresolved external symbol _expm1
 referenced in function _qbeta

 libRmath.a(mlutils.o) : error LNK2019: unresolved external symbol
 ___fpclassify referenced in function _R_pow

 ../Debug/complex_plugin.dll : fatal error LNK1120: 3 unresolved
 externals



 Build log was saved at file://c:\starting point\Debug\BuildLog.htm

 Complex plugin - 7 error(s), 1 warning(s)





 -- Done --



Build: 0 succeeded, 1 failed, 0 skipped



 At first glance, it looks like C:\Rtools\MinGW\lib\libm.a is missing.
 After adding it to my project properties, the results are the same. It
 looks like VC++ is OK with GNU libraries because it appears to accept
 libRmath which was built on the same machine using Rtools. Also it
does
 not appear to be a configuration issue, because it's only found
 'C:\Rtools\MinGW\lib' and VC+ is complaining about not finding it.



 Any ideas?



 Oran




   [[alternative HTML version deleted]]

 __
 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] [rfc] Package to access the internal zlib library.

2008-01-31 Thread jason
And Brian Ripley writes:
 The *only* safe thing to do is to include your own copy of
 zlib, and compile it into the package (optionally linking
 instead to the system copy if it exists).

Fair enough, and likely necessary on AIX with XCOFF's
restrictions.  The Rcompression package mentioned by Duncan Lang
has most of what I need, so I should help with Rcompression
instead.

 Please note that Uwe Ligges provides a Windows testing service:
 see 'Writing R Extensions' and the R-admin manual.  You don't
 need to ask others to do this for you.

Great!  Thank you and Uwe Ligges!  I completely missed the
Services section.

Jason

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


[Rd] X11 device distortion (PR#10666)

2008-01-31 Thread t . zumbrunn
Full_Name: Thomas Zumbrunn
Version: 2.6.1
OS: GNU/Linux (openSuse 10.3 2.6.22.13-0.3-default)
Submission from: (NULL) (131.152.125.199)


With my particular X11 settings, the width to height ratio of the x11 device is
distorted, with the width being half that of the height. This results in wrongly
proportioned plots, wrongly positioned text etc.

Other devices are not affected.

I already asked about his on the mailing list
(https://stat.ethz.ch/pipermail/r-help/2007-December/147891.html) but no one
seemed to have an answer.

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


Re: [Rd] logical operator and addition (PR#10665)

2008-01-31 Thread Duncan Murdoch
[EMAIL PROTECTED] wrote:
 Full_Name: Nicolas Simonis
 Version: 2.6.1
 OS: windows
 Submission from: (NULL) (155.52.10.223)


 Very funny bug :

   
 0.60.6
 
 [1] FALSE
   
 0.60.4+0.2
 
 [1] TRUE

   
I don't see a bug here, I see failure to read FAQ 7.31.  The value 0.6 
is less than 0.4+0.2, when the operation is done in floating point 
approximations.  None of those three numbers is exactly representable.

  (0.4+0.2) - 0.6
[1] 1.110223e-16

Duncan Murdoch
 control :

   
 0.70.7
 
 [1] FALSE
   
 0.70.4+0.3
 
 [1] FALSE

 With R 2.6.1 windows. it's not doing it with R 2.3.1 linux...

 __
 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] logical operator and addition (PR#10665)

2008-01-31 Thread nicolas_simonis
Full_Name: Nicolas Simonis
Version: 2.6.1
OS: windows
Submission from: (NULL) (155.52.10.223)


Very funny bug :

 0.60.6
[1] FALSE
 0.60.4+0.2
[1] TRUE

control :

 0.70.7
[1] FALSE
 0.70.4+0.3
[1] FALSE

With R 2.6.1 windows. it's not doing it with R 2.3.1 linux...

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


Re: [Rd] logical operator and addition (PR#10665)

2008-01-31 Thread ripley
This seems another instance of FAQ Q7.31

 0.6 - (0.4 + 0.2)
[1] -1.110223e-16


On Wed, 30 Jan 2008, [EMAIL PROTECTED] wrote:

 Full_Name: Nicolas Simonis
 Version: 2.6.1
 OS: windows
 Submission from: (NULL) (155.52.10.223)


 Very funny bug :

(rather a very common FAQ, when asked as a question)

 0.60.6
 [1] FALSE
 0.60.4+0.2
 [1] TRUE

 control :

 0.70.7
 [1] FALSE
 0.70.4+0.3
 [1] FALSE

 With R 2.6.1 windows. it's not doing it with R 2.3.1 linux...

It depends on the compiler and optimization settings: it is doing it on 
2.3.1 Linux for me (and 2.6.2 RC).


 __
 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] X11 device distortion (PR#10666)

2008-01-31 Thread ripley
On Thu, 31 Jan 2008, [EMAIL PROTECTED] wrote:

 Full_Name: Thomas Zumbrunn
 Version: 2.6.1
 OS: GNU/Linux (openSuse 10.3 2.6.22.13-0.3-default)
 Submission from: (NULL) (131.152.125.199)


 With my particular X11 settings, the width to height ratio of the x11 device 
 is
 distorted, with the width being half that of the height. This results in 
 wrongly
 proportioned plots, wrongly positioned text etc.

So your X11 settings are wrong: R is just using what X11 tells it.

The most likely setting is DisplaySize in xorg.conf, which controls how
inches are mapped to pixels.


 Other devices are not affected.

 I already asked about his on the mailing list
 (https://stat.ethz.ch/pipermail/r-help/2007-December/147891.html) but no one
 seemed to have an answer.

 __
 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


[Rd] S4: setGeneric() and setMethod() with changed argument order

2008-01-31 Thread Christoph Buser
Dear R devel team

Using S4 classes in R I found a possible source of mistakes
caused by an inattentive user.

If one uses another order of the arguments for a function in the
setGeneric() as in the setMethod() call, one can get undesired
side effects without any warning.

Would it be desirable to include a warning for such cases? Thank
you for a statement.

R code:

## set generic function test1 with 3 arguments
setGeneric(test1, function(object, printit = TRUE, name = tmp)
   standardGeneric(test1))

## Set method for test1 and class numeric, but change the order od the 2nd
##  and 3rd arguments - No warning, everything works well?
setMethod(test1,  signature(object = numeric),
  function(object, name = tmp, printit = TRUE) {
  match.call()
  })

## .local is generated with the order from setGeneric(), but is called
## afterwards with the wrong order from setMethod() which can cause an error
## (if you are lucky) or strange results.
selectMethod(test1, signature = signature(object = numeric))

 Method Definition:
 
 function (object, printit = TRUE, name = tmp) 
 {
 .local - function (object, name = tmp, printit = TRUE) 
 {
 match.call()
 }
 .local(object, printit, name)
 }
 
 Signatures:
 object   
 target  numeric
 defined numeric
 

## Shows that for the argument name printit is used. For the argument
## printit name is used
test1(pi)

 .local(object = object, name = printit, printit = name)



Best regards,

Christoph Buser

--
Christoph Buser [EMAIL PROTECTED]
Seminar fuer Statistik, LEO C13
ETH Zurich  8092 Zurich  SWITZERLAND
phone: x-41-44-632-4673 fax: 632-1228
http://stat.ethz.ch/~buser/

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


Re: [Rd] segfault in gregexpr()

2008-01-31 Thread Seth Falcon
Hi again,

 Herve wrote:
gregexpr(, abc, fixed=TRUE)
 
*** caught segfault ***
   address 0x1c09000, cause 'memory not mapped'

This should be fixed in latest svn.  Thanks for the report.

+ seth

-- 
Seth Falcon | [EMAIL PROTECTED] | blog: http://userprimary.net/user/

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


Re: [Rd] X11 device distortion (PR#10666)

2008-01-31 Thread Hin-Tak Leung
My first thought was that you must be using Xinerama or TwinView -
and you did mention Xinerama in your r-help message but not
in your bug report - this detail is important.

That said, I don't know enough about X11 to say anything - well, maybe
I do, but you'll have to show your xorg.conf , and possibly the result
of xdpyinfo for anybody to help you. I think your Xinerama setup is broken.

for the time being, you could probably run the X11 device through Xnest
to get around this.

[EMAIL PROTECTED] wrote:
 Full_Name: Thomas Zumbrunn
 Version: 2.6.1
 OS: GNU/Linux (openSuse 10.3 2.6.22.13-0.3-default)
 Submission from: (NULL) (131.152.125.199)
 
 
 With my particular X11 settings, the width to height ratio of the x11 device 
 is
 distorted, with the width being half that of the height. This results in 
 wrongly
 proportioned plots, wrongly positioned text etc.
 
 Other devices are not affected.
 
 I already asked about his on the mailing list
 (https://stat.ethz.ch/pipermail/r-help/2007-December/147891.html) but no one
 seemed to have an answer.
 
 __
 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] Problem with R.2.6.1 and JRI - All worked file wih R2.5.1

2008-01-31 Thread Vladmir Makarov
Hello Members,
I have posted this message at R-HELP listserv, so my apology for
double posting, but members of R_HELP seem not to know/care about the
problem.

I wonder if someone also having a problem with JRI using new R 2.6.1.
To illustrate the problem, there is a simple Java driver problem
below. The program runs just fine on the other computer with R 2.5.1,
but does not run with R 2.6.1. It gives me no error messages either.
Needles to say, I have jri.dll at the classpath. Also, I have
downloaded the rJava package from R program (packages  install
packages  rJava), so version must be correct.

Any suggestions are highly appreciated,
Thanks,
Vlad



import org.rosuda.JRI.Rengine;

public class Driver {

public static void main(String[] args){
try {
String[] arg = {};
Rengine re = new Rengine(arg, false, null);
if (!Rengine.versionCheck()) {
Rengine.getVersion();
System.err.println(** Version mismatch);
System.exit(1);
}
if (!re.waitForR()) {
System.out.println(** Cannot load R);
System.exit(1);
}
double d = re.eval(3+5).asDouble();
System.out.print(D =  + d);
} catch (RuntimeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

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


Re: [Rd] X11 device distortion (PR#10666)

2008-01-31 Thread marc_schwartz
Just to follow up, largely in synch with the two replies already, it
sounds like there is a good chance that your two displays (the physical
panels or monitors) are either of two different sizes and/or have two
different resolutions. Somewhat more likely is the latter.

In either case, it is likely that the dpi (dots per inch) setting that
is being picked up by the X server is incorrect or biased by one display
over the other. Hence, when you open the display device on the screen,
the size and aspect ratio of the device is wrong.

For example, on my system, I have an internal 15 inch laptop lcd panel
of 1600x1200 with a dpi of 133. I have an external 20 inch lcd panel
which has the same resolution but at 100 dpi. I happen to use TwinView
with an nVidia card, but have to tweak the xorg.conf settings to get the
displays to look reasonably similar. I actually hard code the 100 dpi
setting rather than allowing the server to get the information from the
monitors. My xdpyinfo is:

$ xdpyinfo | grep dimensions
  dimensions:3200x1200 pixels (813x305 millimeters)

$ xdpyinfo | grep resolution
  resolution:100x100 dots per inch

Note that using TwinView, my two displays effectively show as one.

I would suggest that you post to a SUSE or generic Linux forum or
perhaps to a graphics card vendor forum specific to your card for
detailed guidance.

HTH,

Marc Schwartz


Hin-Tak Leung wrote:
 My first thought was that you must be using Xinerama or TwinView -
 and you did mention Xinerama in your r-help message but not
 in your bug report - this detail is important.
 
 That said, I don't know enough about X11 to say anything - well, maybe
 I do, but you'll have to show your xorg.conf , and possibly the result
 of xdpyinfo for anybody to help you. I think your Xinerama setup is broken.
 
 for the time being, you could probably run the X11 device through Xnest
 to get around this.
 
 [EMAIL PROTECTED] wrote:
 Full_Name: Thomas Zumbrunn
 Version: 2.6.1
 OS: GNU/Linux (openSuse 10.3 2.6.22.13-0.3-default)
 Submission from: (NULL) (131.152.125.199)


 With my particular X11 settings, the width to height ratio of the x11 device 
 is
 distorted, with the width being half that of the height. This results in 
 wrongly
 proportioned plots, wrongly positioned text etc.

 Other devices are not affected.

 I already asked about his on the mailing list
 (https://stat.ethz.ch/pipermail/r-help/2007-December/147891.html) but no one
 seemed to have an answer.

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


[Rd] Pb with lapply()

2008-01-31 Thread hpages
Hi,

If needed, lapply() tries to convert its first argument into a list
before it starts doing something with it:

   lapply
  function (X, FUN, ...) 
  {
FUN - match.fun(FUN)
if (!is.vector(X) || is.object(X)) 
X - as.list(X)
.Internal(lapply(X, FUN))
  }

But in practice, things don't always seem to work as suggested by
this code (at least to the eyes of a naive user).

I have defined an as.list method for my S4 class A:

   setClass(A, representation(data=list))
  [1] A
   setMethod(as.list, A, function(x, ...) [EMAIL PROTECTED])
  Creating a new generic function for as.list in .GlobalEnv
  [1] as.list

Testing it:

   a - new(A, data=list(8, 2:0))
   as.list(a)
  [[1]]
  [1] 8

  [[2]]
  [1] 2 1 0

OK.

But lapply() doesn't work on 'a':

   lapply(a, typeof)
  Error in as.vector(x, list) : cannot type 'S4' coerce to vector

I still have to do the 'as.list(a)' part myself for things to work:

   lapply(as.list(a), typeof)
  [[1]]
  [1] double

  [[2]]
  [1] integer

Seems like using force() inside lapply() would solve the problem:

  lapply2 - function(X, FUN, ...)
  {
FUN - match.fun(FUN)
if (!is.vector(X) || is.object(X))
X - force(as.list(X))
.Internal(lapply(X, FUN))
  }

It works now:

   lapply2(a, typeof)
  [[1]]
  [1] double

  [[2]]
  [1] integer

Cheers,
H.

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


Re: [Rd] Pb with lapply()

2008-01-31 Thread Gabor Grothendieck
The problem of promises not being evaluated in
lists has been discussed before.

I think its fixed in the development version of R. See
r44139 on Jan 24, 2008 in http://developer.r-project.org/R.svnlog.2007

On Jan 31, 2008 1:26 PM,  [EMAIL PROTECTED] wrote:
 Hi,

 If needed, lapply() tries to convert its first argument into a list
 before it starts doing something with it:

   lapply
  function (X, FUN, ...)
  {
FUN - match.fun(FUN)
if (!is.vector(X) || is.object(X))
X - as.list(X)
.Internal(lapply(X, FUN))
  }

 But in practice, things don't always seem to work as suggested by
 this code (at least to the eyes of a naive user).

 I have defined an as.list method for my S4 class A:

   setClass(A, representation(data=list))
  [1] A
   setMethod(as.list, A, function(x, ...) [EMAIL PROTECTED])
  Creating a new generic function for as.list in .GlobalEnv
  [1] as.list

 Testing it:

   a - new(A, data=list(8, 2:0))
   as.list(a)
  [[1]]
  [1] 8

  [[2]]
  [1] 2 1 0

 OK.

 But lapply() doesn't work on 'a':

   lapply(a, typeof)
  Error in as.vector(x, list) : cannot type 'S4' coerce to vector

 I still have to do the 'as.list(a)' part myself for things to work:

   lapply(as.list(a), typeof)
  [[1]]
  [1] double

  [[2]]
  [1] integer

 Seems like using force() inside lapply() would solve the problem:

  lapply2 - function(X, FUN, ...)
  {
FUN - match.fun(FUN)
if (!is.vector(X) || is.object(X))
X - force(as.list(X))
.Internal(lapply(X, FUN))
  }

 It works now:

   lapply2(a, typeof)
  [[1]]
  [1] double

  [[2]]
  [1] integer

 Cheers,
 H.

 __
 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] Pb with lapply()

2008-01-31 Thread hpages
Hi Gabor,

Quoting Gabor Grothendieck [EMAIL PROTECTED]:

 The problem of promises not being evaluated in
 lists has been discussed before.
 
 I think its fixed in the development version of R. See
 r44139 on Jan 24, 2008 in http://developer.r-project.org/R.svnlog.2007
 

I'm using R-devel r44238 and the problem is still here.

Cheers,
H.

 sessionInfo()
R version 2.7.0 Under development (unstable) (2008-01-29 r44238) 
x86_64-unknown-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] stats graphics  grDevices utils datasets  methods   base

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


Re: [Rd] Problem with R.2.6.1 and JRI - All worked file wih R2.5.1

2008-01-31 Thread Simon Urbanek
Vladimir,

your example works without problems in R 2.6.1:

C:\Program Files\R\R-2.6.1\library\rJava\jrijavac -cp JRI.jar  
Driver.java
C:\Program Files\R\R-2.6.1\library\rJava\jriset PATH=C:\Program Files 
\R\R-2.6.1\bin;%PATH%
C:\Program Files\R\R-2.6.1\library\rJava\jrijava -cp JRI.jar;. Driver
D = 8.0

I suspect that you have some setting mismatch left over from your  
previous R version.
Note that you may want to add System.exit(0) or terminate R, otherwise  
your application will be waiting for R to exit.

Cheers,
Simon


On Jan 31, 2008, at 11:37 AM, Vladmir Makarov wrote:

 Hello Members,
 I have posted this message at R-HELP listserv, so my apology for
 double posting, but members of R_HELP seem not to know/care about the
 problem.

 I wonder if someone also having a problem with JRI using new R 2.6.1.
 To illustrate the problem, there is a simple Java driver problem
 below. The program runs just fine on the other computer with R 2.5.1,
 but does not run with R 2.6.1. It gives me no error messages either.
 Needles to say, I have jri.dll at the classpath. Also, I have
 downloaded the rJava package from R program (packages  install
 packages  rJava), so version must be correct.

 Any suggestions are highly appreciated,
 Thanks,
 Vlad



 import org.rosuda.JRI.Rengine;

 public class Driver {

   public static void main(String[] args){
   try {
   String[] arg = {};
   Rengine re = new Rengine(arg, false, null);
   if (!Rengine.versionCheck()) {
   Rengine.getVersion();
   System.err.println(** Version mismatch);
   System.exit(1);
   }
   if (!re.waitForR()) {
   System.out.println(** Cannot load R);
   System.exit(1);
   }
   double d = re.eval(3+5).asDouble();
   System.out.print(D =  + d);
   } catch (RuntimeException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   }
   
   }

 }

 __
 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] Pb with lapply()

2008-01-31 Thread Gabor Grothendieck
I just checked and the
code that previously triggered the promises in lists
bug seems to work now so I guess it is a different
problem.

# code below previously triggered errors but now works
# R 2.6.2 (2008-01-26 r44181) on Vista
f - function(x) environment()
z - as.list(f(7))
dput(z)
structure(list(x = 7), .Names = x)
z[[1]] == 7
force(z[[1]]) == 7


On Jan 31, 2008 2:33 PM,  [EMAIL PROTECTED] wrote:
 Hi Gabor,

 Quoting Gabor Grothendieck [EMAIL PROTECTED]:

  The problem of promises not being evaluated in
  lists has been discussed before.
 
  I think its fixed in the development version of R. See
  r44139 on Jan 24, 2008 in http://developer.r-project.org/R.svnlog.2007
 

 I'm using R-devel r44238 and the problem is still here.

 Cheers,
 H.

  sessionInfo()
 R version 2.7.0 Under development (unstable) (2008-01-29 r44238)
 x86_64-unknown-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] stats graphics  grDevices utils datasets  methods   base





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


[Rd] Feature request: about lag(), which.min() and cat().

2008-01-31 Thread Matthieu Stigler
Hello

I'm only user of R and have many little knowledge in programming but I 
permit to send you some whishes/suggestions for R.

which.min
like which(), which.min() should also include an argument arr.ind. Note 
that one can have it with which(a==min(a), arr.ind=TRUE) but if there is 
a reason to build a special function which.min, why not add also this 
nice argument?

lag()
If one wants to construct a time series model, it is often useful to 
have the lags matrix. This is available with embed(ts,k) but the time 
series class disappears. So it would be nice that the argument k of 
lag() also admit values of length 1, which would give the same result 
as embed() but keep the class. In his wish list of 1 January 2008 (point 
8), Gabor Grothendieck spoke about a function Lag. Maybe also a function 
lags otherwise if the idea of length(k)1 is not good?

cat()
It would be really nice if cat() could also include matrix and lists as 
values. This would allow big improvements for output written in a file.

Thank you for what you make for R, it is a really nice program!

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


Re: [Rd] X11 device distortion (PR#10666)

2008-01-31 Thread Thomas Zumbrunn
On Thursday 31 January 2008, Hin-Tak Leung wrote:
 My first thought was that you must be using Xinerama or TwinView -
 and you did mention Xinerama in your r-help message but not
 in your bug report - this detail is important.

Yes, I forgot to mention this.

 That said, I don't know enough about X11 to say anything - well, maybe
 I do, but you'll have to show your xorg.conf , and possibly the result
 of xdpyinfo for anybody to help you. I think your Xinerama setup is broken.

Yes, and as Prof. Ripley correctly guessed that the DisplaySize setting was 
wrong. SaX2, the X11 setup tool of openSUSE, adds up the width values of both 
Xinerama devices, which results in a wrong DisplaySize width value. I filed a 
bug at openSUSE and already got a reaction. It seems unclear whether it is 
correct to add up the values.

 for the time being, you could probably run the X11 device through Xnest
 to get around this.

Thanks for the advice. Correcting the DisplaySize value helped, and it didn't 
break the Xinerama setting.

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


Re: [Rd] Feature request: about lag(), which.min() and cat().

2008-01-31 Thread Gabor Grothendieck
On Jan 31, 2008 8:24 AM, Matthieu Stigler [EMAIL PROTECTED] wrote:
 lag()
 If one wants to construct a time series model, it is often useful to
 have the lags matrix. This is available with embed(ts,k) but the time
 series class disappears. So it would be nice that the argument k of
 lag() also admit values of length 1, which would give the same result
 as embed() but keep the class. In his wish list of 1 January 2008 (point
 8), Gabor Grothendieck spoke about a function Lag. Maybe also a function
 lags otherwise if the idea of length(k)1 is not good?

It would be nice.  Note that lag.zoo in the zoo package does supports this
for zoo objects.

 library(zoo)
 z - zoo((11:20)^2)
 lag(z, 1:2)
  lag1 lag2
1  144  169
2  169  196
3  196  225
4  225  256
5  256  289
6  289  324
7  324  361
8  361  400
9  400   NA

 # regress z on lag(z, 1:2) using dyn package
 library(dyn)
 dyn$lm(z ~ lag(z, 1:2))

Call:
lm(formula = dyn(z ~ lag(z, 1:2)))

Coefficients:
 (Intercept)  lag(z, 1:2)1  lag(z, 1:2)2
   2 2-1

# as a workaround one could convert to zoo and back

 x - ts((11:20)^2)
 as.ts(lag(as.zoo(x), 1:2))
Time Series:
Start = 1
End = 9
Frequency = 1
  lag1 lag2
1  144  169
2  169  196
3  196  225
4  225  256
5  256  289
6  289  324
7  324  361
8  361  400
9  400   NA


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


Re: [Rd] segfault in gregexpr()

2008-01-31 Thread Herve Pages
Hi Seth,

Seth Falcon wrote:
 Hi again,
 
 Herve wrote:
gregexpr(, abc, fixed=TRUE)

*** caught segfault ***
   address 0x1c09000, cause 'memory not mapped'
 
 This should be fixed in latest svn.  Thanks for the report.

That's great. Thanks!

H.

 
 + seth


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


[Rd] nlme package. Minor change in method print.VarCov (PR#10669)

2008-01-31 Thread agalecki
Hello,

I would like to propose to make a minor change in  method  print.VarCov 
by inserting one line
stdevs -  FALSE  #  Inserted line
as shown later in this email.

By adding this line we would modify the output from
print(corrmtx) as shown in the illustration below. More specifically the
line with redundant information, which reads   Standard Deviations: 1 1 1 
would be skipped from the output.

Otherwise, to omit line with SDs:1 1 1 from the output  we need to use 
more cumbersome syntax:
print(corrmtx, corr=TRUE, stdevs=FALSE).

Output from sessionInfo()  included at the bottom of this email

Sincerely,

Andrzej Galecki



 Illustration  
  selected.rows - seq(1,308, by=10)
  ovary - Ovary[selected.rows,]   # selected rows
  fm1 - gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), ovary, 
correlation = corAR1(form = ~ 1 | Mare))
  vmtx - getVarCov(fm1)   # Covariance matrix
  corrmtx - cov2cor(vmtx)  # Correlation matrix
  print(corrmtx, corr=TRUE)
Marginal correlation matrix
[,1][,2][,3]
[1,] 1.0 0.39172 0.15345
[2,] 0.39172 1.0 0.39172
[3,] 0.15345 0.39172 1.0
  Standard Deviations: 1 1 1
  print(corrmtx,corr=TRUE,stdevs=FALSE)
Marginal correlation matrix
[,1][,2][,3]
[1,] 1.0 0.39172 0.15345
[2,] 0.39172 1.0 0.39172
[3,] 0.15345 0.39172 1.0



==Part of the Source code with suggested change  ===

  getS3method(print,VarCov)
function (x, corr = FALSE, stdevs = TRUE, digits = 5, ...)
{
pvc - function(x, type, corr, stdevs, digits) {
cat(c(Random effects, Conditional, Marginal)[match(type,
c(random.effects, conditional, marginal))],
 , sep = )
x - as.matrix(x)
class(x) - NULL
attr(x, group.levels) - NULL
if (corr) {
cat(correlation matrix\n)
sds - sqrt(diag(x))
print(signif(t(x/sds)/sds, digits))
stdevs -  FALSE  #  Inserted line
   }
else {
cat(variance covariance matrix\n)
print(signif(x, digits))
if (stdevs)
sds - sqrt(diag(x))
}
 


===

  sessionInfo()
R version 2.6.1 (2007-11-26)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

other attached packages:
[1] nlme_3.1-86

loaded via a namespace (and not attached):
[1] grid_2.6.1 lattice_0.17-2 tools_2.6.1   
 

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