From Remy.Drouilhet at upmf-grenoble.fr  Tue Dec  9 11:30:36 2003
From: Remy.Drouilhet at upmf-grenoble.fr (Remy.Drouilhet@upmf-grenoble.fr)
Date: Tue Dec  9 11:29:09 2003
Subject: [Rd] Maybe some bug on sapply and cbind (PR#5628)
Message-ID: <20031209103036.3021DF4E7@slim.kubism.ku.dk>

Full_Name: Drouilhet R?my
Version: 1.8.1
OS: Linux
Submission from: (NULL) (195.221.43.136)


Hi!!!

Is there some mistake?
This is some part of one of my R programs. I created this function to show you
the trouble!!!

bugTest<-function() {
  paramnames <- c("mean","sd")
  param <- list(expression(1),expression(2))
  paramtmp <- list(mean=0,sd=1)
  if(length(param)) {
      sapply(1:length(param),function(i)
paramtmp[[paramnames[i]]]<<-param[[i]])
  }
  paramtmp
}

If you run :

> bugTest()
$mean
expression(1)

$sd
expression(2)

Everything seems Ok!!! But, now, continue by running :
> cbind(1,rep(2,1))
Segmentation fault

In fact, every cbind, rbind applying vectors seem to fail.

Now, change in the bugTest the sapply by some for instance:

bugTest2<-function() {
  paramnames <- c("mean","sd")
  param <- list(expression(1),expression(2))
  paramtmp <- list(mean=0,sd=1)
  if(length(param)) {
      for( i in 1:length(param)) paramtmp[[paramnames[i]]]<-param[[i]]
  }
  paramtmp
}

>  bugTest2()
$mean
expression(1)

$sd
expression(2)

>  cbind(1,rep(2,1))
     [,1] [,2]
[1,]    1    2

NOW, EVERYTHING IS OK!!!

I hope this could be helpful for us!!

Bye


[Rd] Maybe some bug on sapply and cbind (PR#5628)
Remy.Drouilhet@upmf-grenoble.fr