[Rd] Buidling R on Linux (Itanium) fails (PR#7897)

2005-05-25 Thread Bader
Full_Name: Reinhold Bader
Version: 2.1.0
OS: SLES 9
Submission from: (NULL) (129.187.48.1)


I tried to build R using the Intel compilers (icc, ifort) and the Math Kernel
Libraries
for BLAS/LAPACK

Optimizations used were -O3, and the 
FPICFLAGS="-fpic"
was exported.

The build failed with the following error message:
...
dumping R code in package 'methods'
Saving namespace image ...
initializing class and method definitions now ...Error in
makePrototypeFromClassDef(properties, ClassDef, immediate, where) :
in making the prototype for class "SClassExtension" elements of the
prototype failed to match the corresponding slot class: coerce (class
“character” ), test (class “character” ), replace (class “character” ), simple
(class “character” ), dataPart (class “character” )
Error: .onLoad failed in 'loadNamespace' for 'methods'
Execution halted

I am not a R specialist; how do I continue from here?
make[4]: *** [../..

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


Re: [Rd] R OS X

2005-05-25 Thread Simon Urbanek

On May 24, 2005, at 9:11 AM, Volker Runkel wrote:


with newest R.app (1.11) / R2.1.0a

if a package is installed for the current user, it is not installed  
properly (does not get an installed version entry and is not  
loadable). If installed system wide it works.


As Rob mentioned, you likely didn't select "Add $RHOME/R/Library" in  
Startup preferences of R.app.
I just want to add for the record that R versions before 2.1.0a  
(including 2.1.0 release in particular) featured a bug that caused ~/ 
R/library to be always in .libPaths even if R.app or the user  
disabled it (in --gui=AQUA mode).


Cheers,
Simon

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


[Rd] seek(con, 0, "end", rw="r") does not always work correctly (PR#7896)

2005-05-25 Thread tplate
I've noticed that seek(con, 0, "end", rw="r") on a file connection does 
not always work correctly after a write (R 2.1.0 on Windows).

[Is a call to fflush() needed inside file_seek() in main/connections.c?]

Example (see the lines with the "***WRONG***" comment)

 > # seek(, rw="r") on a file does not always work correctly after a write
 > f <- file("tmp3.txt", "w+b")
 > # Write something earlier in the file
 > seek(f, 10, rw="w")
[1] 0
 > writeLines(c("ghi", "jkl"), f)
 > seek(f, 20, rw="w")
[1] 18
 > writeLines(c("abc"), f)
 > seek(f, 0, "end", rw="w")
[1] 24
 > # Try to read at the end of the file
 > seek(f, 0, "end", rw="r")
[1] 0
 > readLines(f, -1)
character(0)
 > seek(f, 0, "end", rw="w")
[1] 18
 > # write something at the end of the file
 > writeLines(c("def"), f)
 > # Try to read at the end of the file
 > # flush(f) # flushing here makes the seek work correctly
 > seek(f, 0, "end", rw="r")
[1] 24
 > seek(f, NA, rw="r") # ***WRONG*** (should return 28)
[1] 24
 > readLines(f, -1) # ***WRONG*** (should return character(0))
[1] "def"
 > seek(f, 20, rw="r")
[1] 28
 > readLines(f, -1)
[1] "abc" "def"
 > seek(f, 0, "end", rw="r") # now it works correctly
[1] 28
 > seek(f, NA, rw="r")
[1] 28
 > readLines(f, -1)
character(0)
 > close(f)
 >
 > version
  _
platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major2
minor1.0
year 2005
month04
day  18
language R
 >

-- Tony Plate

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


[Rd] Request: scan() argument 'allowEscapes' in read.table() too, please.

2005-05-25 Thread Henrik Bengtsson
I would like to suggest adding argument 'allowEscapes' to 
read.table(..., allowEscapes=TRUE) and pass it to its three calls to 
scan(..., allowEscapes=allowEscapes).


Rd (from ?scan):
\item{allowEscapes}{logical. Should C-style escapes such as '\n' be 
processed (the default) or read verbatim?   Note that if not within 
quotes these could be interpreted as a delimiter (but not as a comment 
character).}


Currently, it is not possible to use read.table() to read tab-delimited 
files with elements containing the string "\t" (not a TAB), i.e. the two 
characters "\" and "t". Example:



A   B
1   a\tb
2   c\td



AB
1a\tb
2c\td


Try to read the above with

scan(stdin(), what=character(0), sep="\t", allowEscapes=FALSE)

and this

scan(stdin(), what=character(0), sep="\t", allowEscapes=TRUE)

Cheers

Henrik Bengtsson

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


Re: [Rd] Rout for library/base/R-ex/Extract.data.frame.R

2005-05-25 Thread Paul Gilbert

Martin Maechler wrote:


"UweL" == Uwe Ligges <[EMAIL PROTECTED]>
   on Wed, 25 May 2005 11:08:18 +0200 writes:



UweL> Vadim Ogranovich wrote:
>> Hi,
>> 
>> I am writing a light-weight data frame class and want to

>> borrow the test cases from the standard data frame. I
>> found the test cases in
>> library/base/R-ex/Extract.data.frame.R, but surprisingly
>> no corresponding .Rout files. In fact there is no *.Rout
>> file in the entire tarball. Not that I cann't generate
>> them, but I am just curious why they are not there? How
>> does the base package get tested?
>> 
>> Thanks, Vadim


UweL> The base packages have their test cases in ...R/tests
UweL> rather than R/src/library/packagename

yes, and the *examples* from the help pages are just run, and
not compared to prespecified output in *.Rout.save (sic!) files.
In an *installed* (not the source!) version of R or an R package 
you find the R code for all the examples from the help pages
in /R-ex/*.R.   
That's the same for all R packages, not just the standard

packages.


Vadim

I'll expand a bit on Martin's comment. It is hard to test the output of 
all examples because some examples use random numbers, and for others 
the precision may vary a bit on different platforms. I typically add 
important examples to the tests directory, set the random number 
generation, and compare results within tolerances that work on different 
platforms.


Paul Gilbert


Martin Maechler

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


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


Re: [Rd] Rout for library/base/R-ex/Extract.data.frame.R

2005-05-25 Thread Martin Maechler
> "UweL" == Uwe Ligges <[EMAIL PROTECTED]>
> on Wed, 25 May 2005 11:08:18 +0200 writes:

UweL> Vadim Ogranovich wrote:
>> Hi,
>> 
>> I am writing a light-weight data frame class and want to
>> borrow the test cases from the standard data frame. I
>> found the test cases in
>> library/base/R-ex/Extract.data.frame.R, but surprisingly
>> no corresponding .Rout files. In fact there is no *.Rout
>> file in the entire tarball. Not that I cann't generate
>> them, but I am just curious why they are not there? How
>> does the base package get tested?
>> 
>> Thanks, Vadim

UweL> The base packages have their test cases in ...R/tests
UweL> rather than R/src/library/packagename

yes, and the *examples* from the help pages are just run, and
not compared to prespecified output in *.Rout.save (sic!) files.
In an *installed* (not the source!) version of R or an R package 
you find the R code for all the examples from the help pages
in /R-ex/*.R.   
That's the same for all R packages, not just the standard
packages.

Martin Maechler

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


[Rd] Error with user defined split function in rpart (PR#7895)

2005-05-25 Thread wheelerb
Full_Name: Bill Wheeler
Version: 2.0.1
OS: Windows 2000
Submission from: (NULL) (67.130.36.229)


The program to reproduce the error is below. I am calling rpart with a
user-defined split function for a binary response variable and one continuous
independent variable. The split function works for some datasets but not
others.
The error is:
Error in "$<-.data.frame"(`*tmp*`, "yval2", value = c(0, 15, 10, 0.6,  : 
replacement has 5 rows, data has 1


#
# Test out the "user mode" functions, with a binary response
# 

rm(list=ls(all=TRUE))

options(warn = 1);
library(rpart);

set.seed(7);

nobs <- 25;
mydata<- data.frame(indx=1:nobs);
mydata[, "y"] <- floor(runif(nobs, min=0, max=2));
mydata[, "x"] <- runif(nobs, min=0, max=2);
mydata$indx   <- NULL;


# The 'evaluation' function.  Called once per node.
#  Produce a label (1 or more elements long) for labeling each node,
#  and a deviance.  The latter is
#   - of length 1
#   - equal to 0 if the node is "pure" in some sense (unsplittable)
#   - does not need to be a deviance: any measure that gets larger
#as the node is less acceptable is fine.
#   - the measure underlies cost-complexity pruning, however
temp1 <- function(y, wt, parms) {
 print("* START: TEMP1 *");
 
n <- length(y);

# Get the number of y's in each category
sumyEqual0 <- sum(y == 0);
sumyEqual1 <- sum(y == 1);

# Get the proportion of 0's and 1's
p0 <- sumyEqual0/n;
p1 <- sumyEqual1/n;

if (p0 >= p1) {
  dev = sumyEqual1;
} else {
  dev = sumyEqual0;
}
  
# Get the vector of labels
labels <- matrix(nrow=1, ncol=5);

# labels[1] is the fitted y category
# labels[2] is sum(y == 0)
# labels[3] is sum(y == 1)
# labels[4] is sum(y == 0)/n
# labels[5] is sum(y == 1)/n

if (p0 >= p1) {
  labels[1] = 0;
} else {
  labels[1] = 1;
}
labels[2] <- sumyEqual0;
labels[3] <- sumyEqual1;
labels[4] <- sumyEqual0/n;
labels[5] <- sumyEqual1/n;

ret <- list(label=labels, deviance=dev)
 

print("* END: TEMP1 *");
ret
}

# The split function, where most of the work occurs.
#   Called once per split variable per node.
# If continuous=T
#   The actual x variable is ordered
#   y is supplied in the sort order of x, with no missings,
#   return two vectors of length (n-1):
#  goodness = goodness of the split, larger numbers are better.
# 0 = couldn't find any worthwhile split
#the ith value of goodness evaluates splitting obs 1:i vs (i+1):n
#  direction= -1 = send "y< cutpoint" to the left side of the tree
#  1 = send "y< cutpoint" to the right
# this is not a big deal, but making larger "mean y's" move towards
# the right of the tree, as we do here, seems to make it easier to
# read
# If continuos=F, x is a set of integers defining the groups for an
#   unordered predictor.  In this case:
#   direction = a vector of length m= "# groups".  It asserts that the
#   best split can be found by lining the groups up in this order
#   and going from left to right, so that only m-1 splits need to
#   be evaluated rather than 2^(m-1)
#   goodness = m-1 values, as before.
#
# The reason for returning a vector of goodness is that the C routine
#   enforces the "minbucket" constraint. It selects the best return value
#   that is not too close to an edge.
temp2 <- function(y, wt, x, parms, continuous) {
print("* START: TEMP2 *");
 
n <- length(y)
 
# For binary y, get P(Y=0)/n and P(Y=1)/n at each split
temp <- cumsum(y*wt)[-n]
 
left.wt  <- cumsum(wt)[-n]  
right.wt <- sum(wt) - left.wt
   
lp <- temp/left.wt
 
rsum <- matrix(nrow=1, ncol=n-1, data=0);
for (i in seq(1, n-1))
{
  for (j in seq(i+1, n))
  {
rsum[i] <- rsum[i] + y[j];
  }  
}

rp <- rsum/right.wt
 
lprop <- 1 - lp;
rprop <- rp;
 
# Get the direction
direc <- matrix(nrow=1, ncol=length(lp), data=1);
for (i in seq(1, length(lp)))
{
  if (lprop[i] >= rprop[i])
direc[i] <- -1;
}
   
goodness <- (lprop + rprop);
  
ret <- list(goodness= goodness, direction=direc)
  
print("* END: TEMP2 *");

ret
}

# The init function:
#   fix up y to deal with offsets
#   return a dummy parms list
#   numresp is the number of values produced by the eval routine's "label"
#   numy is the number of columns for y
#   summary is a function used to print one line in summary.rpart
#   text is a function used to put text on the plot in text.rpart
# In general, this function would also check for bad data, see rpart.poisson
#   for instace.
temp3 <- function(y, offset, parms, wt) {
print("* START: TEMP3 *");
 
if (!is.null(offset)) y <- y-offset
ret <- list(y=y, parms=0, num

Re: [Rd] R-exts.texi: nuke-trailing-whitespace has changed name (PR#7888)

2005-05-25 Thread Martin Maechler
Thank you,
Bjørn-Helge,

> "BjøHM" == Bjørn-Helge Mevik <[EMAIL PROTECTED]>
> on Sun, 22 May 2005 22:56:49 +0200 (CEST) writes:

  ..

BjøHM> In Appendix B R coding standards of the Writing R
BjøHM> Extensions manual, Emacs/ESS users are encouraged to
BjøHM> use

BjøHM> ..

BjøHM> However, as of ess-5.2.4 (current is 5.2.8)
BjøHM> `nuke-trailing-whitespace' has changed name to
BjøHM> `ess-nuke-trailing-whitespace'.

BjøHM> In addition: by default, ess-nuke-trailing-whitespace
BjøHM> is a no-op (as was nuke-trailing-whitespace).  To
BjøHM> `activate' it one must set
BjøHM> ess-nuke-trailing-whitespace-p to t or 'ask (default
BjøHM> is nil), e.g.  (setq ess-nuke-trailing-whitespace-p t)

Thank you. I've now changed it to

-

.
.

(add-hook 'local-write-file-hooks
  (lambda ()
(ess-nuke-trailing-whitespace)
(setq ess-nuke-trailing-whitespace-p 'ask)
;; or even
;; (setq ess-nuke-trailing-whitespace-p t)

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


Re: [Rd] Rout for library/base/R-ex/Extract.data.frame.R

2005-05-25 Thread Uwe Ligges

Vadim Ogranovich wrote:


Hi,
 
I am writing a light-weight data frame class and want to borrow the test

cases from the standard data frame. I found the test cases in
library/base/R-ex/Extract.data.frame.R, but surprisingly no
corresponding .Rout files. In fact there is no *.Rout file in the entire
tarball. Not that I cann't generate them, but I am just curious why they
are not there? How does the base package get tested?
 
Thanks,

Vadim

[[alternative HTML version deleted]]

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



The base packages have their test cases in
...R/tests rather than R/src/library/packagename

Uwe Ligges

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


Re: [Rd] Using a C++ library to read a binary file

2005-05-25 Thread Uwe Ligges

Demitri Muna wrote:


Hello,

I am trying to use a C++ library I have to read some data into R.  I've 
gone over the "Writing R Extensions" page and some of the  archives, but 
am left somewhat confused (and I'm still very new to R!).


What I want to do is fairly simple. Given some parameters, I'd like  to 
read a string of numbers from a proprietary binary file into an  array. 
I have a C++ library that will read anything I need from this  file.


What is the best way to do this? Can someone give me any pointers to  
sample code?


You might be able to write a C wrapper around your C++ code and link 
that into R, so R can get the data directly from a .C() call to your 
wrapper function. See Writing R Extensions for details.



One possibility I've considered is writing a small unix command line  
program that, given the parameters, will return the string of  numbers. 
Is there a way to "capture" this from R into an array?


Yes, this way will also work, please read the R Data Import/Export 
manual and ?connection.


Uwe Ligges




Cheers,

Demitri

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


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