Re: [Rd] problem building R packages on RHEL 4 Linux with Intel compilers

2008-05-30 Thread Martin Maechler
 SU == Simon Urbanek [EMAIL PROTECTED]
 on Thu, 29 May 2008 20:06:21 -0400 writes:

SU On May 29, 2008, at 6:11 PM, Mark Kimpel wrote:

 Esmail and Simon, I would direct you to the very first sentence of my
 original post, I would like to build R and packages with the Intel  
 10.1
 compilers in RHEL4. I DO NOT want to build with gcc, that is the  
 very point
 of this thread. Does anyone have an answer to my original question?  
 I need
 to know what flags to put with configure so that packages will be  
 compiled
 with Intel 10.1 when I do install.packages from within R.
 

SU You'll get that *if* the package is not broken and you compiled R with  
SU icc.

But if I read Mark's very first post correctly,
he tried to build R with icc (and ifort, and their libraries)
that he didn't succeed  already there,
but rather gave the ./configure  error message he'd
reported.

Is that correct Mark?
{Not that I could really help further here with the configure problem}

Martin Maechler, ETH Zurich

SU  However, many packages don't use autoconf properly which results  
SU in broken configure scripts (the configure will use a different  
SU compiler and flags than R, effectively making it useless).

SU So, in order to furter help you, you have to be more specific (which  
SU package we're talking about for example)...


SU Cheers,
SU Simon


 
 On Thu, May 29, 2008 at 5:54 PM, Simon Urbanek [EMAIL PROTECTED] 
 
 wrote:
 
 
 On May 29, 2008, at 5:45 PM, Mark Kimpel wrote:
 
 Simon, I scanned the config.log, which is too voluminous to insert  
 below,
 but it seems that gcc is still being looked for as the compiler.  
 See the
 lines from config.log below. Mark
 
 Thread model: posix
 gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)
 configure:4824: $? = 0
 configure:4831: gcc -V 5
 gcc: `-V' option must have argument
 configure:4834: $? = 1
 configure:4857: checking for C compiler default output file name
 configure:4884: gcc -fast -unroll -wd188 -I/usr/local/include -L -L
 -L/usr/local/lib64 conftest.c  5
 gcc: unrecognized option `-wd188'
 cc1: error: unrecognized command line option -fast
 
 
 ^^ there you go: -fast is not supported by your gcc and -wd188 is
 ignored (whatever you're trying achieve with that) ... it's there  
 in plain
 english ;).
 
 Cheers,
 Simon
 
 
 
 
 configure:4887: $? = 1
 configure:4925: result:
 configure: failed program was:
 | /* confdefs.h.  */
 
 # Then the tail end of config.log
 
 r_cc_lo_rules_frag=''
 r_cc_rules_frag=''
 r_cxx_rules_frag=''
 r_objc_rules_frag=''
 
 ## --- ##
 ## confdefs.h. ##
 ## --- ##
 
 #define PACKAGE_NAME R
 #define PACKAGE_TARNAME R
 #define PACKAGE_VERSION 2.7.0
 #define PACKAGE_STRING R 2.7.0
 #define PACKAGE_BUGREPORT [EMAIL PROTECTED]
 #define PACKAGE R
 #define VERSION 2.7.0
 #define R_PLATFORM x86_64-unknown-linux-gnu
 #define R_CPU x86_64
 #define R_VENDOR unknown
 #define R_OS linux-gnu
 #define Unix 1
 #define R_ARCH 
 
 configure: exit 77
 
 
 On Thu, May 29, 2008 at 5:35 PM, Simon Urbanek 
 [EMAIL PROTECTED] wrote:
 
 On May 29, 2008, at 5:01 PM, Mark Kimpel wrote:
 
 I am installing within my home folder, see the ./configure  
 options. I've
 never had a permission problem before and, like I said, if I don't  
 put all
 the Intel-specific flags in the ./configure, everything works fine.
 
 
 This has nothing to do with the executable bit and/or permissions  
 - this
 is about the compiler rejecting your flags. Have a look in  
 config.log that's
 where you'll find out what the compiler didn't like (and the error  
 clearly
 tells you that ;)).
 
 Cheers,
 Simon
 
 
 On Thu, May 29, 2008 at 4:41 PM, Esmail Bonakdarian [EMAIL PROTECTED] 
 
 wrote:
 
 Mark Kimpel wrote:
 
 
 checking for gcc... gcc
 checking for C compiler default output file name...
 configure: error: C compiler cannot create executables
 See `config.log' for more details.
 
 
 Are you running this as root? Or do you have the right
 privileges for the install?
 
 The cannot create executables looks like a permission problem
 
 Esmail
 
 
 
 
 --
 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)
 
 **
 
 [[alternative HTML 

Re: [Rd] problem building R packages on RHEL 4 Linux with Intel compilers

2008-05-30 Thread Prof Brian Ripley

On Fri, 30 May 2008, Martin Maechler wrote:

[Adding Mark Kimpel back to the recipients]


SU == Simon Urbanek [EMAIL PROTECTED]
on Thu, 29 May 2008 20:06:21 -0400 writes:


   SU On May 29, 2008, at 6:11 PM, Mark Kimpel wrote:

Esmail and Simon, I would direct you to the very first sentence of my
original post, I would like to build R and packages with the Intel
10.1
compilers in RHEL4. I DO NOT want to build with gcc, that is the
very point
of this thread. Does anyone have an answer to my original question?
I need
to know what flags to put with configure so that packages will be
compiled
with Intel 10.1 when I do install.packages from within R.
   

   SU You'll get that *if* the package is not broken and you compiled R with
   SU icc.

But if I read Mark's very first post correctly,
he tried to build R with icc (and ifort, and their libraries)
that he didn't succeed  already there,
but rather gave the ./configure  error message he'd
reported.

Is that correct Mark?
{Not that I could really help further here with the configure problem}


That was my reading of the text but not of the subject line.

If so, we need access to config.log to see the problem.  Please put it on 
a website somewhere.


It would also help to know why Mark Kimpel wants to do this -- people have 
not found the Intel compilers particularly effective and there are quite a 
few reports of wrong answers using them.  I suspect -fast is not going to 
work, as on our Intel 9 compilers it forces static linking.


A very useful general strategy is to start with a minimal set (often none) 
of extra flags and build up to the optimization level required.  So please 
try that before supplying config.log.




Martin Maechler, ETH Zurich

   SU  However, many packages don't use autoconf properly which results
   SU in broken configure scripts (the configure will use a different
   SU compiler and flags than R, effectively making it useless).

   SU So, in order to furter help you, you have to be more specific (which
   SU package we're talking about for example)...


   SU Cheers,
   SU Simon


   
On Thu, May 29, 2008 at 5:54 PM, Simon Urbanek [EMAIL PROTECTED]

wrote:
   
   
On May 29, 2008, at 5:45 PM, Mark Kimpel wrote:
   
Simon, I scanned the config.log, which is too voluminous to insert
below,
but it seems that gcc is still being looked for as the compiler.
See the
lines from config.log below. Mark
   
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)
configure:4824: $? = 0
configure:4831: gcc -V 5
gcc: `-V' option must have argument
configure:4834: $? = 1
configure:4857: checking for C compiler default output file name
configure:4884: gcc -fast -unroll -wd188 -I/usr/local/include -L -L
-L/usr/local/lib64 conftest.c  5
gcc: unrecognized option `-wd188'
cc1: error: unrecognized command line option -fast
   
   
^^ there you go: -fast is not supported by your gcc and -wd188 is
ignored (whatever you're trying achieve with that) ... it's there
in plain
english ;).
   
Cheers,
Simon
   
   
   
   
configure:4887: $? = 1
configure:4925: result:
configure: failed program was:
| /* confdefs.h.  */
   
# Then the tail end of config.log
   
r_cc_lo_rules_frag=''
r_cc_rules_frag=''
r_cxx_rules_frag=''
r_objc_rules_frag=''
   
## --- ##
## confdefs.h. ##
## --- ##
   
#define PACKAGE_NAME R
#define PACKAGE_TARNAME R
#define PACKAGE_VERSION 2.7.0
#define PACKAGE_STRING R 2.7.0
#define PACKAGE_BUGREPORT [EMAIL PROTECTED]
#define PACKAGE R
#define VERSION 2.7.0
#define R_PLATFORM x86_64-unknown-linux-gnu
#define R_CPU x86_64
#define R_VENDOR unknown
#define R_OS linux-gnu
#define Unix 1
#define R_ARCH 
   
configure: exit 77
   
   
On Thu, May 29, 2008 at 5:35 PM, Simon Urbanek 
[EMAIL PROTECTED] wrote:
   
On May 29, 2008, at 5:01 PM, Mark Kimpel wrote:
   
I am installing within my home folder, see the ./configure
options. I've
never had a permission problem before and, like I said, if I don't
put all
the Intel-specific flags in the ./configure, everything works fine.
   
   
This has nothing to do with the executable bit and/or permissions
- this
is about the compiler rejecting your flags. Have a look in
config.log that's
where you'll find out what the compiler didn't like (and the error
clearly
tells you that ;)).
   
Cheers,
Simon
   
   
On Thu, May 29, 2008 at 4:41 PM, Esmail Bonakdarian [EMAIL PROTECTED]

wrote:
   
Mark Kimpel wrote:
   
   
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: C compiler cannot create executables
See `config.log' for more details.
   
   
Are you running this as root? Or do you have 

Re: [Rd] problem building R packages on RHEL 4 Linux with Intel compilers

2008-05-30 Thread Bjørn-Helge Mevik
Mark Kimpel [EMAIL PROTECTED] writes:

 I would like to build R and packages with the Intel 10.1 compilers in RHEL4.

We are successfully building R and packages with the Intel 10.1
compilers on RHEL4 (except a few packages, which will not compile with
10.1, but with 9.1).  We also use the Intel MKL blas/lapack libraries.

This is out procedure for building R:

export CC=icc
export CFLAGS=-O3 -ip -wd188
export F77=ifort
export FFLAGS=-O3 -ip
export CXX=icpc
export CXXFLAGS=-O3 -ip
export FC=ifort
export FCFLAGS=-O3 -ip -mp

./configure --prefix=/site/VERSIONS/R-2.7.0 \
  --with-blas=-L/site/intel/cmkl/8.1/lib/em64t -lmkl -lvml -lguide -lpthread \
  --with-lapack=-L/site/intel/cmkl/8.1/lib/em64t -lmkl_lapack64 -lmkl \
  --enable-R-shlib

make -j 4

make -j 4 check # NB! -j 4 won't work on all versions of R

make install

Packages are installed with install.packages() in R.  The procedure is
loosely based on the Intel/MKL examples given in the R Installation and
Administration Manual.

The only thing we haven't figured out how to solve, is how to also
generate the libRblas.so and libRlapack.so; --enable-BLAS-shlib seems to
interfer with the --with-lapack, such that the extarnal library will not
be used.

-- 
Regards,
Bjørn-Helge Mevik

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


Re: [Rd] Listing all possible samples of Size two form Large Population

2008-05-30 Thread Ben Bolker
Nadeem Shafique nadeemshafique at gmail.com writes:

 
 Respected All,
 
 I need some efficient program or package to draw all possible samples
 of size two without replacement. I am using combinat package to list
 all possible samples but it hangs my computer for larger populations
 say 10,000 (i.e. 49995000 all possible samples). I wish to even work
 for larger populations then this and replicate this procedure for many
 times. Kindly can anyone figure out the possibilities and let me know.
 

50 million samples sounds like a lot already -- hope you
have a lot of memory (and I am tempted to wonder what you're
going to find out that a random subsample wouldn't tell you ...)

object.size(numeric(5e7))/2^20
[1] 381.4697

 -- already 381MB (although maybe you have a lot of memory),
and you have to double that to hold both elements of the
combination.

The algorithm for enumerating these samples by brute force is
pretty easy --

for (i in 2:N) {
for (j in 1:(i-1)) {
   cat(i,j,\n)
 }
}

  -- but of course these loops will be really slow for large N.
There may (?) be a way to do this in a vectorized fashion
(the only quick and dirty ways I can think of doing this
involve creating the whole sample and then cutting it down,
which is probably not worth the time, e.g.

 N = 10
 i=1:N
 j=1:N
 e=expand.grid(i,j)
 m=matrix(1:nrow(e),nrow=N)
 s=e[m[lower.tri(m)],]

  I would create a little snippet of C code to do this.
You could also look at the inline package (on CRAN) or
Ra and the jit package, although both of these are more
experimental than just writing the C code, compiling it,
and linking it in.

  Bottom line: this should be possible, but I don't
know of a package that does it automatically, and if I
were you I would think seriously about what question you
really want to answer and whether there's a less brute-force
way of doing it.

  cheers
Ben Bolker

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


[Rd] Quartile summary generated by density() is misleading (PR#11541)

2008-05-30 Thread ierickson
Full_Name: Ian Erickson
Version: 2.5.1 (2007-06-27)
OS: x86_64-redhat-linux-gnu
Submission from: (NULL) (204.16.153.138)


The quartile breaks reported by the density() function should intuitively be
cumulative density quartiles for the distribution being estimated. However, what
is calculated is instead simple quartiles for points used to plot the generated
curve.

Example: running density(rnorm(10)) gives a 1st quartile of -2.2, and a 3rd
quartile of +2.2. However, graphing the density using
plot(density(rnorm(10))) shows what would be expected - at -2.2, the
cumulative density is only a few percent rather than 25%.

Let me know if you have questions - the current calculated quartile numbers are
trivially just the range of the data divided by 4.

Thanks.

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


[Rd] help (using ?) does not handle trailing whitespace (PR#11537)

2008-05-30 Thread rocket
 ?agrep 
 

Results in:

No documentation for 'agrep ' in specified packages and libraries:
you could try 'help.search(agrep )'

There is white space after agrep, that ? doesn't ignore.


--please do not edit the information below--

Version:
 platform = i486-pc-linux-gnu
 arch = i486
 os = linux-gnu
 system = i486, linux-gnu
 status = 
 major = 2
 minor = 7.0
 year = 2008
 month = 04
 day = 22
 svn rev = 45424
 language = R
 version.string = R version 2.7.0 (2008-04-22)

Locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, 
package:datasets, package:showStructure, package:Rcode, package:splus2R, 
package:methods, Autoloads, package:base

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


[Rd] Reading an unsigned long long using R readBin()

2008-05-30 Thread Sean Davis
Sorry for the simple question, but I am trying to read an unsigned
long long using the R readBin() function.  Can someone point me in
the right direction, or am I better off using C for such things?  The
file that I am reading will have been produced on the same machine
that is doing the reading.

Thanks,
Sean

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


[Rd] scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)

2008-05-30 Thread rocket
I've run into a scoping problem in R.
I'm calling a function that
   * creates a formula
   * calculates a weight vector
   * calls lm with that formula and weights
This fails.

Here's a simplified reproduce example:
# f works, g doesn't, h is a workaround
rm(w)
data - data.frame(y=runif(20), x=runif(20), z=runif(20))
f - function(k){
  w - data$z^k
  coef(lm(y~x, data = data, weights = w))
}
g - function(k){
  w - data$z^k
  Formula - parse(text=y~x)[[1]]
  coef(lm(Formula, data = data, weights = w))
}
h - function(k){
  w - data$z^k
  Formula - parse(text=y~x)[[1]]
  # Following line fails due to scoping bug.  Use workaround.
  # coef(lm(Formula, data = data, weights = w))
  Call - paste(coef(lm(, deparse(Formula), , data=data, weights=w)))
  eval(parse(text=Call)[[1]])
}


 f(2)
(Intercept)   x 
  0.7452512  -0.3413998 
 g(2)
Error in eval(expr, envir, enclos) : object w not found
 traceback()
9: eval(expr, envir, enclos)
8: eval(extras, data, env)
7: model.frame.default(formula = Formula, data = data, weights = w, 
   drop.unused.levels = TRUE)
6: model.frame(formula = Formula, data = data, weights = w, drop.unused.levels 
= TRUE)
5: eval(expr, envir, enclos)
4: eval(mf, parent.frame())
3: lm(Formula, data = data, weights = w)
2: coef(lm(Formula, data = data, weights = w))
1: g(2)
 h(2)
(Intercept)   x 
  0.7452512  -0.3413998 



--please do not edit the information below--

Version:
 platform = i486-pc-linux-gnu
 arch = i486
 os = linux-gnu
 system = i486, linux-gnu
 status = 
 major = 2
 minor = 7.0
 year = 2008
 month = 04
 day = 22
 svn rev = 45424
 language = R
 version.string = R version 2.7.0 (2008-04-22)

Locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

Search Path:
 .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, 
package:datasets, package:showStructure, package:Rcode, package:splus2R, 
package:methods, Autoloads, package:base

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


Re: [Rd] Reading an unsigned long long using R readBin()

2008-05-30 Thread Simon Urbanek


On May 29, 2008, at 2:41 PM, Sean Davis wrote:

Sorry for the simple question, but I am trying to read an unsigned  
long long using the R readBin() function.  Can someone point me in  
the right direction, or am I better off using C for such things?   
The file that I am reading will have been produced on the same  
machine that is doing the reading.




R has no data type that can hold 64-bit integers (long long), so there  
is no (lossless) way to read such a field in R.
If you know the endianness of the machine you can read two integers  
and combine the result as a float to get an approximate value.  
Otherwise C is your friend (and easy to call from R) for 64-bit  
calculations, bitwise operations and other tricks that are hard to do  
in R.


Cheers,
Simon

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


Re: [Rd] Reading an unsigned long long using R readBin()

2008-05-30 Thread Prof Brian Ripley
Well, R has no unsigned quantities, so ultimately you can't actually do 
this.  But using what=int and an appropriate 'size' (likely to be 8)

shold read the numbers, wrapping around very large ones to be negative.
(The usual trick of storing integers in numeric will lose accuracy, but 
might be better than nothing.)


On Thu, 29 May 2008, Sean Davis wrote:


Sorry for the simple question, but I am trying to read an unsigned
long long using the R readBin() function.  Can someone point me in
the right direction, or am I better off using C for such things?  The
file that I am reading will have been produced on the same machine
that is doing the reading.

Thanks,
Sean

__
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] scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)

2008-05-30 Thread Gabor Grothendieck
Try replacing the last line in g with:

lmout - do.call(lm, list(Formula, data = data, weights = w))
coef(lmout)

or replace w with environment()$w thereby explicitly telling it where to look.


On Fri, May 30, 2008 at 11:40 AM,  [EMAIL PROTECTED] wrote:
 I've run into a scoping problem in R.
 I'm calling a function that
   * creates a formula
   * calculates a weight vector
   * calls lm with that formula and weights
 This fails.

 Here's a simplified reproduce example:
 # f works, g doesn't, h is a workaround
 rm(w)
 data - data.frame(y=runif(20), x=runif(20), z=runif(20))
 f - function(k){
  w - data$z^k
  coef(lm(y~x, data = data, weights = w))
 }
 g - function(k){
  w - data$z^k
  Formula - parse(text=y~x)[[1]]
  coef(lm(Formula, data = data, weights = w))
 }
 h - function(k){
  w - data$z^k
  Formula - parse(text=y~x)[[1]]
  # Following line fails due to scoping bug.  Use workaround.
  # coef(lm(Formula, data = data, weights = w))
  Call - paste(coef(lm(, deparse(Formula), , data=data, weights=w)))
  eval(parse(text=Call)[[1]])
 }


 f(2)
 (Intercept)   x
  0.7452512  -0.3413998
 g(2)
 Error in eval(expr, envir, enclos) : object w not found
 traceback()
 9: eval(expr, envir, enclos)
 8: eval(extras, data, env)
 7: model.frame.default(formula = Formula, data = data, weights = w,
   drop.unused.levels = TRUE)
 6: model.frame(formula = Formula, data = data, weights = w, 
 drop.unused.levels = TRUE)
 5: eval(expr, envir, enclos)
 4: eval(mf, parent.frame())
 3: lm(Formula, data = data, weights = w)
 2: coef(lm(Formula, data = data, weights = w))
 1: g(2)
 h(2)
 (Intercept)   x
  0.7452512  -0.3413998



 --please do not edit the information below--

 Version:
  platform = i486-pc-linux-gnu
  arch = i486
  os = linux-gnu
  system = i486, linux-gnu
  status =
  major = 2
  minor = 7.0
  year = 2008
  month = 04
  day = 22
  svn rev = 45424
  language = R
  version.string = R version 2.7.0 (2008-04-22)

 Locale:
 LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

 Search Path:
  .GlobalEnv, package:stats, package:graphics, package:grDevices, 
 package:utils, package:datasets, package:showStructure, package:Rcode, 
 package:splus2R, package:methods, Autoloads, package:base

 __
 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] Reading an unsigned long long using R readBin()

2008-05-30 Thread Duncan Murdoch

On 5/30/2008 1:55 PM, Prof Brian Ripley wrote:
Well, R has no unsigned quantities, so ultimately you can't actually do 
this.  But using what=int and an appropriate 'size' (likely to be 8)

shold read the numbers, wrapping around very large ones to be negative.
(The usual trick of storing integers in numeric will lose accuracy, but 
might be better than nothing.)


I think reading size 8 integers on 32 bit Windows returns signed 32 bit 
integers, with values outside that range losing the high order bits, not 
just accuracy.  At least that's what I see when I write the numbers 1:10 
out as 4 byte integers, and read them as 8 byte integers:  I get 1 3 5 7 9.


Duncan Murdoch



On Thu, 29 May 2008, Sean Davis wrote:


Sorry for the simple question, but I am trying to read an unsigned
long long using the R readBin() function.  Can someone point me in
the right direction, or am I better off using C for such things?  The
file that I am reading will have been produced on the same machine
that is doing the reading.

Thanks,
Sean

__
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] scoping problem when calling lm(precomputed formula, weights) (PR#11543)

2008-05-30 Thread murdoch
On 5/30/2008 11:40 AM, [EMAIL PROTECTED] wrote:
 I've run into a scoping problem in R.

No, in your use of it.

 I'm calling a function that
* creates a formula

... incorrectly.

* calculates a weight vector
* calls lm with that formula and weights
 This fails.
 
 Here's a simplified reproduce example:
 # f works, g doesn't, h is a workaround
 rm(w)
 data - data.frame(y=runif(20), x=runif(20), z=runif(20))
 f - function(k){
   w - data$z^k
   coef(lm(y~x, data = data, weights = w))
 }
 g - function(k){
   w - data$z^k
   Formula - parse(text=y~x)[[1]]

If this were simply

Formula - y ~ x

it would work, because then the formula would get the evaluation 
environment attached.  I assume your real case builds up a formula in 
text and then parses it, in which case you'll have to evaluate the 
formula to get the environment set:

  g
function (k)
{
 w - data$z^k
 Formula - eval(parse(text = y ~ x))
 coef(lm(Formula, data = data, weights = w))
}
  g(2)
(Intercept)   x
   0.419  -0.7023185

In more complicated cases, you may need to explicitly set the 
environment of the constructed formula, using e.g.

environment(Formula) - environment()

Duncan Murdoch

   coef(lm(Formula, data = data, weights = w))
 }
 h - function(k){
   w - data$z^k
   Formula - parse(text=y~x)[[1]]
   # Following line fails due to scoping bug.  Use workaround.
   # coef(lm(Formula, data = data, weights = w))
   Call - paste(coef(lm(, deparse(Formula), , data=data, weights=w)))
   eval(parse(text=Call)[[1]])
 }
 
 
 f(2)
 (Intercept)   x 
   0.7452512  -0.3413998 
 g(2)
 Error in eval(expr, envir, enclos) : object w not found
 traceback()
 9: eval(expr, envir, enclos)
 8: eval(extras, data, env)
 7: model.frame.default(formula = Formula, data = data, weights = w, 
drop.unused.levels = TRUE)
 6: model.frame(formula = Formula, data = data, weights = w, 
 drop.unused.levels = TRUE)
 5: eval(expr, envir, enclos)
 4: eval(mf, parent.frame())
 3: lm(Formula, data = data, weights = w)
 2: coef(lm(Formula, data = data, weights = w))
 1: g(2)
 h(2)
 (Intercept)   x 
   0.7452512  -0.3413998 
 
 
 
 --please do not edit the information below--
 
 Version:
  platform = i486-pc-linux-gnu
  arch = i486
  os = linux-gnu
  system = i486, linux-gnu
  status = 
  major = 2
  minor = 7.0
  year = 2008
  month = 04
  day = 22
  svn rev = 45424
  language = R
  version.string = R version 2.7.0 (2008-04-22)
 
 Locale:
 LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C
 
 Search Path:
  .GlobalEnv, package:stats, package:graphics, package:grDevices, 
 package:utils, package:datasets, package:showStructure, package:Rcode, 
 package:splus2R, package:methods, Autoloads, package:base
 
 __
 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] (PR#11537) help (using ?) does not handle trailing whitespace

2008-05-30 Thread Prof Brian Ripley

We don't know how to reproduce this: 'whitespace' is not specific enough.

R's tokenizer breaks input at spaces, so a space would never be part of 
that expression.  And tabs don't even get to the parser in interactive 
use, and you cannot mean a newline.  So exactly what do you mean by 
'whitespace'?


The character in your email as received here is an ASCII space, and that 
is used to end the token on all my systems.  That's not to say that you 
didn't type something else that looks like a space (e.g. a nbspace) since 
email systems are fickle.


None of my guesses worked, so we need precise reproduction instructions.

On Thu, 29 May 2008, [EMAIL PROTECTED] wrote:


?agrep



Results in:

No documentation for 'agrep ' in specified packages and libraries:
you could try 'help.search(agrep )'

There is white space after agrep, that ? doesn't ignore.


--please do not edit the information below--

Version:
platform = i486-pc-linux-gnu
arch = i486
os = linux-gnu
system = i486, linux-gnu
status =
major = 2
minor = 7.0
year = 2008
month = 04
day = 22
svn rev = 45424
language = R
version.string = R version 2.7.0 (2008-04-22)

Locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

Search Path:
.GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, 
package:datasets, package:showStructure, package:Rcode, package:splus2R, 
package:methods, Autoloads, package:base

__
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] NAMESPACE methods guidance, please

2008-05-30 Thread Martin Morgan
My conception of how NAMESPACE and methods in R-2.7.0 resolved a
generic 'func' to a func-method was to search as follows:

In 2.7.0:

func --
NAMESPACE, including Imports: (and other details) --
.GlobalEnv, and eventually Depends: since these are on search()

In R-devel it seems like

func --
NAMESPACE, including Imports: (and other details) --
?? but not pkgs in Depends:

Is this correct or as intended, or is there a better conception to
have?

This model is from the following:

In 2.7.0:

 library(KEGG.db) # Imports, Depends AnnotationDbi; KEGG.db is data-only
 head(ls(KEGGPATHID2EXTID))
[1] hsa00232 hsa00230 hsa04514 hsa04010 hsa04012 hsa04150

vs. in a package tmpA with a NAMESPACE with Depend: and Imports:
KEGG.db and in a new session of R

 library(tmpA)
 dokegg
function () 
{
require(KEGG.db)
head(ls(KEGGPATHID2EXTID))
}
environment: namespace:tmpA
 dokegg()
[1] hsa00232 hsa00230 hsa04514 hsa04010 hsa04012 hsa04150

In R-devel

 dokegg()
Error in as.environment(pos) : invalid object for 'as.environment'
Error in head(ls(KEGGPATHID2EXTID)) : 
  error in evaluating the argument 'x' in selecting a method for function 'head'

In some ways this seems good (tmpA author has to specify use of
AnnotationDbi::ls, and tmpA is not confused by things the user does to
their environment) but in other ways it seems to undo any benefit of
method dispatch and requires the tmpA author to fully discover (and
monitor -- what if AnnotationDbi splits 'ls' into a AnnotationBase
pkg?) the class hierarchy.

The specific example of KEGG.db and AnnotationDbi is maybe more
interesting than others, because there is really no functionality to
be imported from KEGG.db.

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

Location: Arnold Building M2 B169
Phone: (206) 667-2793

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


Re: [Rd] Reading an unsigned long long using R readBin()

2008-05-30 Thread Bill Dunlap
On Fri, 30 May 2008, Prof Brian Ripley wrote:

 On Fri, 30 May 2008, Duncan Murdoch wrote:

  On 5/30/2008 1:55 PM, Prof Brian Ripley wrote:
  Well, R has no unsigned quantities, so ultimately you can't actually do
  this.  But using what=int and an appropriate 'size' (likely to be 8)
  shold read the numbers, wrapping around very large ones to be negative.
  (The usual trick of storing integers in numeric will lose accuracy, but
  might be better than nothing.)
 
  I think reading size 8 integers on 32 bit Windows returns signed 32 bit
  integers, with values outside that range losing the high order bits, not 
  just
  accuracy.  At least that's what I see when I write the numbers 1:10 out as 4
  byte integers, and read them as 8 byte integers:  I get 1 3 5 7 9.

 Yes, that's true for even larger ones.

 So to clarify: up to 2^31-1 should work, thereafter you will get the lower
 32 bits and hence possibly a signed number.

When we wrote a version of readBin() for Splus 8.0 we added an
extra argument, output=, that specifies the type of S object
to put the result into.  The what= argument says what sort
of data is in the input file and by default output=what.
output=double can be useful in this case, as a double can
store a 53 bit signed or unsigned integer without loss of
precision.  If the integer is bigger than 2^53-1, the double
stores its most significant 53 bits, which may be better
than truncating the thing.

E.g., I wrote a C program to write some unsigned long longs to
a file:
#include stdio.h
int main(int argc, char *argv[])
{
unsigned long long data[7], one = 1ULL ;
data[0] = one ;
data[1] = (one31) - 1 ;
data[2] = (one31) + 1 ;
data[3] = (one32) - 1 ;
data[4] = (one32) + 1 ;
data[5] = (one52) + 1 ;
data[6] = (one54) + 1 ;
(void)fwrite((void *)data, sizeof(data[0]), 
sizeof(data)/sizeof(data[0]), stdout) ;
return 0 ;
}

od shows what it writes, as unsigned, signed, and hex
8 byte integers:
% ./a.out|od --format u8
0001   2147483647
020   2147483649   4294967295
040   4294967297 4503599627370497
06018014398509481985
070
% ./a.out | od --format d8
0001   2147483647
020   2147483649   4294967295
040   4294967297 4503599627370497
06018014398509481985
070
% ./a.out | od --format x8
000 0001 7fff
020 8001 
040 00010001 0011
060 0041
070

and in 32-bit Splus I can read it with:
 z-readBin(pipe(./a.out, open=br), what=integer, n=7,
  size=8, signed=FALSE, output=double)
 print(z, digits=16)
[1] 1214748364721474836494294967295
[5]4294967297  4503599627370497 18014398509481984
Note that it loses precision where z[7]2^53.

Without the output=double then the numbers  2^32 would be
truncated and the signs would be wrong on ones between 2^31
anbd 2^32:
 readBin(pipe(./a.out, open=br), what=integer, n=7,
  size=8, signed=FALSE)
[1]   1  2147483647 -2147483647  -1   1   1
[7]   1
(That one gives the same result in R and Splus.)

What do folks think about having this option in R?


Bill Dunlap
Insightful Corporation
bill at insightful dot com

 All statements in this message represent the opinions of the author and do
 not necessarily reflect Insightful Corporation policy or position.

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


[Rd] Request: Documentation of formulae

2008-05-30 Thread Mike Prager
In working through material on p.272 of MASS (4th ed.), I came
across the following model formula:

pet1.lm - lm(Y ~ No/EP - 1, Petrol)

I was at a loss to understand the use of / until I looked in
An Introduction [!] to R, where I found the explanation. 

My request is that more complete material on model formulae be
lifted from Introduction to R (or elsewhere) and put into the
main online help files. There are other useful notations that
may not be well known. Since formulae are not limited to any
particular function, perhaps an entry could be made under
Formula.

More justification:

The help for lm does not explain this notation, nor did I find
a cross-reference to anything useful there. The R Reference
Manual seems to explain functions only. The R Language
Definition has no index entry for formula or model formulae.

Looking to print, neither the section on model formula on p.56
of MASS nor the section surrounding the above example explains
the notation, nor could I find it in Dalgaard's book, nor in
Maindonald and Braun.  

This seems too nice a feature to keep hidden in plain sight.

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

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


Re: [Rd] Request: Documentation of formulae

2008-05-30 Thread markleeds
 This isn't particularly helpful because the book is  quite old but 
formula notation/functionality is covered in depth in Statistical 
Models in S by
Chambers and Hastie.  My guess is that there is strong consistency 
between what is said in there and how things work in R.




On Fri, May 30, 2008 at  4:19 PM, Mike Prager wrote:


In working through material on p.272 of MASS (4th ed.), I came
across the following model formula:

pet1.lm - lm(Y ~ No/EP - 1, Petrol)

I was at a loss to understand the use of / until I looked in
An Introduction [!] to R, where I found the explanation.
My request is that more complete material on model formulae be
lifted from Introduction to R (or elsewhere) and put into the
main online help files. There are other useful notations that
may not be well known. Since formulae are not limited to any
particular function, perhaps an entry could be made under
Formula.

More justification:

The help for lm does not explain this notation, nor did I find
a cross-reference to anything useful there. The R Reference
Manual seems to explain functions only. The R Language
Definition has no index entry for formula or model formulae.

Looking to print, neither the section on model formula on p.56
of MASS nor the section surrounding the above example explains
the notation, nor could I find it in Dalgaard's book, nor in
Maindonald and Braun.
This seems too nice a feature to keep hidden in plain sight.

--
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
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] (PR#11537) help (using ?) does not handle trailing whitespace

2008-05-30 Thread Prof Brian Ripley
I think it is ESS that is parsing this as a help request (so it can divert 
it to an ESS buffer).


Looks like this is an ESS issue, not an R one.

Using ?agrep  will fail in R, but that seems correct as there is no 
topic agrep .


On Fri, 30 May 2008, Tim Hesterberg wrote:


By whitespace, I mean either a space or tab (preceding the newline).

I'm using ESS:
ess-version's value is 5.3.6
GNU Emacs 21.4.1 (i486-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of
2007-08-28 on terranova, modified by Debian

I have the following in my .emacs:
(load ess-5.3.6/lisp/ess-site)
(setq ess-tab-always-indent nil)
(setq ess-fancy-comments nil)

I have not edited ess-site.el


On Fri, May 30, 2008 at 12:26 PM, Prof Brian Ripley
[EMAIL PROTECTED] wrote:

We don't know how to reproduce this: 'whitespace' is not specific enough.

R's tokenizer breaks input at spaces, so a space would never be part of that
expression.  And tabs don't even get to the parser in interactive use, and
you cannot mean a newline.  So exactly what do you mean by 'whitespace'?

The character in your email as received here is an ASCII space, and that is
used to end the token on all my systems.  That's not to say that you didn't
type something else that looks like a space (e.g. a nbspace) since email
systems are fickle.

None of my guesses worked, so we need precise reproduction instructions.

On Thu, 29 May 2008, [EMAIL PROTECTED] wrote:


?agrep



Results in:

No documentation for 'agrep ' in specified packages and libraries:
you could try 'help.search(agrep )'

There is white space after agrep, that ? doesn't ignore.


--please do not edit the information below--

Version:
platform = i486-pc-linux-gnu
arch = i486
os = linux-gnu
system = i486, linux-gnu
status =
major = 2
minor = 7.0
year = 2008
month = 04
day = 22
svn rev = 45424
language = R
version.string = R version 2.7.0 (2008-04-22)

Locale:

LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

Search Path:
.GlobalEnv, package:stats, package:graphics, package:grDevices,
package:utils, package:datasets, package:showStructure, package:Rcode,
package:splus2R, package:methods, Autoloads, package:base

__
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





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