From Kurt.Hornik@ci.tuwien.ac.at  Mon Jul 28 14:23:49 1997
From: Kurt.Hornik@ci.tuwien.ac.at (Kurt Hornik)
Date: Mon, 28 Jul 1997 15:23:49 +0200
Subject: R-alpha: R 0.50.a1 unlist() problems
Message-ID: <199707281323.PAA18658@aragorn.ci.tuwien.ac.at>

Two things.

TASKS has

TASK:	Naming with Numeric Values and "unlist"
STATUS:	Open
FROM:	<hornik@ci.tuwien.ac.at>
	R> l <- list("11" = 1:5)
	R> l
	$11
	[1] 1 2 3 4 5
	R> unlist(l)
	111 112 113 114 115 
	  1   2   3   4   5 
	[ Bug or feature ? ]

This seems to be a feature (at least, SPLUS does the same), so please
close that task.

***

However, please add the following.

***********************************************************************
R> x <- rnorm(20)
R> y <- rnorm(20)
R> z <- lm(y ~ x)

R> typeof(z)
[1] "list"

R> unlist(z)
[[1]]
[1] 0.07030757

[[2]]
[1] -0.1790483

[[3]]
NULL

[[4]]
NULL

and many more ending in

[[152]]
NULL

[[153]]
NULL

[[154]]
NULL
***********************************************************************

This seems to be a BUG.  SPLUS gives

***********************************************************************
 coefficients.(Intercept)       coefficients.x         residuals.1 
 "-0.322342946956607"     "-0.351990317000716" "-1.05699395125055"
          residuals.2          residuals.3          residuals.4 
 "0.0685214529487529" "-0.825270557482947" "-0.309643367007542"
          residuals.5         residuals.6          residuals.7 
 "-0.970498865234358" "0.239072541069321" "-0.203418862242607"
           residuals.8          residuals.9        residuals.10 
 "-0.0279508657540235" "-0.546704750104556" "-1.41036201719063"
         residuals.11         residuals.12       residuals.13 
 "-0.177627379541701" "-0.159357852715235" "1.01771682562243"
***********************************************************************

etc etc

I haven't looked into the unlist code at all.  Here's another problem.

***********************************************************************
R> l <- list(a = list(1:5, LETTERS[1:5]), b = "Z", c = NA)
R> l
$a
$a[[1]]
[1] 1 2 3 4 5

$a[[2]]
[1] "A" "B" "C" "D" "E"


$b
[1] "Z"

$c
[1] NA

R> unlist(l)
INTERNAL ERROR: ans_nnames = 10    ans_length = 12
Error: incorrect names vector length
***********************************************************************

Hmm ...

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


R-alpha: R 0.50.a1 unlist() problems
Kurt Hornik