[R] Can't Destroy Dim Names

Phil Spector spector at stat.berkeley.edu
Wed Dec 1 00:14:31 CET 2010


Does this help?

> a = c(one=1,two=2,three=3)
> str(a)
  Named num [1:3] 1 2 3
  - attr(*, "names")= chr [1:3] "one" "two" "three"
> names(a) = NULL
> str(a)
  num [1:3] 1 2 3

For a matrix called mat, you'd need to use

dimnames(mat) = NULL

to remove the dimnames.

But remember that, other than when you're displaying the
object, the names or dimnames should not affect anything
you do with the object, and they do allow you to index
elements by name instead of number.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu


On Tue, 30 Nov 2010, 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.
>
> -----
> 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
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list