Re: [R] Can't Destroy Dim Names
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] CA CC CG CT ... 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@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.
Re: [R] Can't Destroy Dim Names
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 spec...@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] CA CC CG CT ... 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@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. __ R-help@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.
Re: [R] Can't Destroy Dim Names
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] CA CC CG CT ... 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 __ R-help@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.
Re: [R] Can't Destroy Dim Names
Dear David To confirm, your method worked. I am not allowed to divulge the original data (financial data), but here comes another set. Test_DF-data.frame(Figure=c(A,B,A,B), Code=c(C, C, D, D), No=c(1,2,3.5,4)) ?data.frame View(Test_DF) str(Test_DF) Test_DF_m-melt(Test_DF, measure=No) View(Test_DF_m) Test_DF_c-cast(Test_DF_m, Figure~Code) str(Test_DF_c) Basically, after the casting the variables the naming appears. If one then goes forth with this item, and does some operations on them (in my case with the zoo package), and ends up with the same cube, but just chr as row/column names but actually the same ones and then tries to merge them (abind). The set above doesn't replicate strangely everything my set does, ind adds a lot more attributes even though I go through the same commands. So the bottom line is where I would expect a simple 2 by 2 matrix with row and column names after the melt and cast, it is a much more complex object and I think tearing off all the rest might be a good thing before proceeding. This is the background to the question. - Christian Langkamp christian.langkamp-at-gmxpro.de -- View this message in context: http://r.789695.n4.nabble.com/Can-t-Destroy-Dim-Names-tp876633p3066484.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.
[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] CA CC CG CT ... 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@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.
Re: [R] Can't Destroy Dim Names
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 gunda...@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] CA CC CG CT ... 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@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? __ R-help@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.
Re: [R] Can't Destroy Dim Names
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.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Gundala Viswanath Sent: Monday, January 12, 2009 6:32 PM To: r-h...@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] CA CC CG CT ... 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@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. __ R-help@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.