[R] Bug in formals<-

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Sep 27 01:09:58 CEST 2006


On 9/26/06, Frank E Harrell Jr <f.harrell at vanderbilt.edu> wrote:
> I think this is new since a previous version of R:
>
>  > h <- function(x, trantab) trantab[x]
>  > w <- 6:4
>  > names(w) <- c('cat','dog','giraffe')
>  > w
>      cat     dog giraffe
>        6       5       4
>  >
>  > formals(h) <- list(x=numeric(0), trantab=w)
>  > h
> function (x = numeric(0), trantab = c(6, 5, 4))
> trantab[x]
>
> You can see that the names have been dropped from trantab's default
> values.

Are you sure? I get

> formals(h)
$x
numeric(0)

$trantab
    cat     dog giraffe
      6       5       4

> h(1)
cat
  6

R version 2.4.0 beta (2006-09-21 r39463)
x86_64-unknown-linux-gnu

-Deepayan


> Version 2.3.1 (2006-06-01)
> i486-pc-linux-gnu
>
> attached base packages:
> [1] "grid"      "methods"   "stats"     "graphics"  "grDevices" "utils"
> [7] "datasets"  "base"
>
> other attached packages:
>    lattice   acepack     Hmisc
> "0.13-10" "1.3-2.2"  "3.0-12"
>
>
> --
> Frank E Harrell Jr   Professor and Chair           School of Medicine
>                       Department of Biostatistics   Vanderbilt University
>



More information about the R-help mailing list