Dear all, I have the following matrix:> str(mat)Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... - attr(*, "names")= chr [1:32268] "CAAAAAAAAA" "CAAAAAAAAC" "CAAAAAAAAG" "CAAAAAAAAT" ... I want to destroy the attribute yielding only this:> str(mat)Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... But why this command fail to do it?> dimnames(mat) <- NULLBtw, the object size for keeping matrix with dim names is greater than without, right? - Gundala Viswanath Jakarta - Indonesia
Is this what you want:> x <- c(a=1, b=2, c=3) > str(x)Named num [1:3] 1 2 3 - attr(*, "names")= chr [1:3] "a" "b" "c"> names(x) <- NULL > x[1] 1 2 3>On Mon, Jan 12, 2009 at 8:32 PM, Gundala Viswanath <gundalav at gmail.com> wrote:> Dear all, > > I have the following matrix: > >> str(mat) > Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... > - attr(*, "names")= chr [1:32268] "CAAAAAAAAA" "CAAAAAAAAC" > "CAAAAAAAAG" "CAAAAAAAAT" ... > > > I want to destroy the attribute yielding only this: > >> str(mat) > Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... > > > But why this command fail to do it? > >> dimnames(mat) <- NULL > > Btw, the object size for keeping matrix with dim names is greater > than without, right? > > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
Your mat variable is not a matrix, but a vector (a named vector), therefore it does not have dimensions or dimnames. Try names(mat) <- NULL Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Gundala Viswanath > Sent: Monday, January 12, 2009 6:32 PM > To: r-help at stat.math.ethz.ch > Subject: [R] Can't Destroy Dim Names > > Dear all, > > I have the following matrix: > > > str(mat) > Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... > - attr(*, "names")= chr [1:32268] "CAAAAAAAAA" "CAAAAAAAAC" > "CAAAAAAAAG" "CAAAAAAAAT" ... > > > I want to destroy the attribute yielding only this: > > > str(mat) > Named chr [1:32268] "yQAAA" "jQAAQ" "UQAAg" "FQAAw" "1QABA" ... > > > But why this command fail to do it? > > > dimnames(mat) <- NULL > > Btw, the object size for keeping matrix with dim names is greater > than without, right? > > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > 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.