Sorry My previous report is not detailed. In R, you will get this:> mylist <- list() > mylist[[1]]Error in mylist[[1]] : subscript out of bounds> mylist[[1]] <- c(1)Error: (list) object cannot be coerced to vector type 14> mylist[[1]] <- c(1,2) > mylist[[1]] <- c(1) > mylist[[1]] [1] 1 I was trying to assigning c(1) to (mylist[[1]] <- c(1)) -- it seems impossible if I dont' assign something else to it in advance. (although a walk around would be mylist[1] <- list(1)) In SPLUS 4 or 3.4, the reactions are different:> mylist <- list() > mylist[[1]]NULL> mylist[[1]] <- c(1) > mylist[[1]]: [1] 1 On Sun, 9 May 1999, Wenxin Mao wrote:> Date: Sun, 9 May 1999 12:42:29 -0400 (EDT) > From: Wenxin Mao <mao@stat.wharton.upenn.edu> > To: r-bugs@biostat.ku.dk > Subject: subscripting in list() > > > In R, (0.64 Binary, Linux 5.0) I tried this command and get an error > message: > > > mylist <- list() > > mylist[[1]] > Error in mylist[[1]] : subscript out of bounds > > It thus makes my Splus programs un-runable, because in SPlus 4.0 or 3.4, > you have > > > mylist <- list() > > mylist[[1]] > NULL > > instead of a stop message. > > > Thanks, > vincent > > > > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Sun, 9 May 1999 mao@compstat.wharton.upenn.edu wrote:> > Sorry My previous report is not detailed. > > In R, you will get this: > > > mylist <- list() > > mylist[[1]] > Error in mylist[[1]] : subscript out of boundsYes, that is a known difference, I believe deliberate.> > mylist[[1]] <- c(1) > Error: (list) object cannot be coerced to vector type 14I get no error in 0.64.1, the current version (since Friday): try upgrading.> > In R, (0.64 Binary, Linux 5.0) I tried this command and get an error > > message:(I assume you tried 0.64.0: there is no 0.64 that I know of.) I do suggest though that you only index lists by names: relying on the order of list components is fraught with possibilities for error. -- Brian D. Ripley, ripley@stats.ox.ac.uk 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._