[R] names function not working at the 2nd place in a program
macqueen1 at llnl.gov
Fri Jul 27 00:20:23 CEST 2012
I rather suspect you don't understand what it means to name an array.
Consider this example:
> myvar <- 1:4> myvar
 1 2 3 4
> names(myvar) <- letters[1:4]
a b c d
1 2 3 4
 "a" "b" "c" "d"
 NA NA NA NA
NAs introduced by coercion
does not name the array.
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
On 7/26/12 2:19 PM, "zz" <czhang at uams.edu> wrote:
>I am using names function to name an array.
>It works first time when I use *as.numeric(names(myVar1)*
>However, at a place later, when I tried to use a very similar line of code
>*as.numeric(names(myVar2)*, it always returned 'numeric(0)' (or if I only
>type 'names(myVar2), it gave me NULL'.
>Both myVar1 and myVar2 are type of integer. The only difference that I
>tell is where the names function are called in my code.
>Does anyone have an idea what may cause the problem?
>Thanks in advance.
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help