[R] Can't Destroy Dim Names
    David Winsemius 
    dwinsemius at comcast.net
       
    Wed Dec  1 00:31:22 CET 2010
    
    
  
On Nov 30, 2010, at 6:07 PM, clangkamp wrote:
> Dear Jim
> I think the target is to get from a Named chr to a just chr
>>> str(mat)
>> Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ...
>> - attr(*, "names")= chr [1:32268] "CAAAAAAAAA" "CAAAAAAAAC"
>> "CAAAAAAAAG" "CAAAAAAAAT" ...
>
> I have presumably the same problem
>> str(DC1a)
> num [1:18, 1:48, 1:35] 3124.4 3049.2 227.8 41.4 76 ...
> - attr(*, "dimnames")=List of 3
>  ..$ Figure  : Named chr [1:18]  "CDS1" ...
>  .. ..- attr(*, "names")= chr [1:18] "1"
>  ..$ Code    : Named chr [1:48] "AGR"
> .. ..- attr(*, "names")= chr [1:48] "1" "36" "71" "106" ...
>  ..$ variable: Named chr [1:35] "X30.09.2009" "
> .. ..- attr(*, "names")= chr [1:35] "1" "2" "3" "4" ...
>> DC1_SM<-abind(DC1a, DC1_PLCF_SM1, along=1, new.names=)
>> str(DC1_SM)
> num [1:24, 1:48, 1:35] 3124.4 3049.2 227.8 41.4 76 ...
> - attr(*, "dimnames")=List of 3
>  ..$ : chr [1:24]  "CDS1" ...
>  ..$ : chr [1:48] "AGR"
>  ..$ : chr [1:35] "X30.09.2009" "
>
> names(dimnames(DC1_PLCF_SM1))<-names(dimnames(DC1a))
>
> The point is to kill the lines with the bit
> .. ..- attr(*, "names")= chr [1:35] "1" "2" "3" "4" ...
> and change the "Named chr" into a plain chr.
It is not at all clear to me that the problem posed a year and a half  
ago is the same as the one you perceive you are facing. In any event  
you are welcome to mangle your object (which you have not offered for  
testing) by turning a named dimension name vector into an unnamed one:
?unname
?Extract
DCtest <- array(1:27, c(3,3,3))
dimnames(DCtest) <- list(dim1 =c(a="a",b="b",c="c"),   #named vector
                             dim2=letters[4:6],            #unnamed  
vectors
                             dim3= letters[7:9])
 > str(DCtest)
  int [1:3, 1:3, 1:3] 1 2 3 4 5 6 7 8 9 10 ...
  - attr(*, "dimnames")=List of 3
   ..$ dim1: Named chr [1:3] "a" "b" "c"
   .. ..- attr(*, "names")= chr [1:3] "a" "b" "c"
   ..$ dim2: chr [1:3] "d" "e" "f"
   ..$ dim3: chr [1:3] "g" "h" "i"
 > dimnames(DCtest)[1]
$dim1
   a   b   c
"a" "b" "c"
 > dimnames(DCtest)[[1]]
   a   b   c
"a" "b" "c"
So use the [[<- function to replace the named vector with an unnamed  
one:
 > dimnames(DCtest)[[1]] <- unname( dimnames(DCtest)[[1]] )
 > str(DCtest)
  int [1:3, 1:3, 1:3] 1 2 3 4 5 6 7 8 9 10 ...
  - attr(*, "dimnames")=List of 3
   ..$ dim1: chr [1:3] "a" "b" "c"
   ..$ dim2: chr [1:3] "d" "e" "f"
   ..$ dim3: chr [1:3] "g" "h" "i"
>
> -----
> Christian Langkamp
> christian.langkamp-at-gmxpro.de
>
> -- 
> View this message in context: http://r.789695.n4.nabble.com/Can-t-Destroy-Dim-Names-tp876633p3066413.html
David Winsemius, MD
West Hartford, CT
    
    
More information about the R-help
mailing list