You can use: print(dd1, row.names=F) # Chisq DF Pr(>Chisq) term 153.0216306 1 7.578366e-35 # Sex 13.3696538 1 5.114571e-04 # Volume 0.8476713 1 7.144239e-01 # Weight 1.2196050 1 5.388764e-01 # Intensity 2.6349405 1 2.090719e-01 # ISO 6.0507714 1 2.780045e-02 # SEC
A.K. On Friday, July 4, 2014 10:27 AM, Gang Chen <gangch...@gmail.com> wrote: I really your kind help! This is exactly what I was looking for except that I need to get rid of the numbered row names. On July 3, 2014 9:57:00 PM EDT, arun <smartpink...@yahoo.com> wrote: Hi, >May be this helps: >nC <- max(nchar(row.names(dd))) > term <- formatC(row.names(dd), width=-nC) >#or > term <- sprintf("%-11s", row.names(dd)) > > dd1 <- setNames(data.frame(unname(dd), term,stringsAsFactors=F), >c(colnames(dd), formatC("term",width=-nC))) >dd1 ># # Chisq DF Pr(>Chisq) term >#1 153.0216306 1 7.578366e-35 # Sex >#2 13.3696538 1 5.114571e-04 # Volume >#3 0.8476713 1 7.144239e-01 # Weight >#4 1.2196050 1 5.388764e-01 # Intensity >#5 2.6349405 1 2.090719e-01 # ISO >#6 6.0507714 1 2.780045e-02 # SEC > >A.K. > > > > > >On Thursday, July 3, 2014 3:57 PM, Gang Chen <gangch...@gmail.com> wrote: >I have a matrix 'dd' defined as below: > >dd <- t(matrix(c(153.0216306, 1, 7.578366e-35, >13.3696538, 1, 5.114571e-04, >0.8476713, 1, 7.144239e-01, >1.2196050, 1, 5.388764e-01, >2.6349405, 1, 2.090719e-01, >6.0507714, 1, 2.780045e-02), nrow=3, ncol=6)) >dimnames(dd)[[2]] <- c('# Chisq', 'DF', 'Pr(>Chisq)') >dimnames(dd)[[1]] <- c('# Sex', '# Volume', '# Weight', '# Intensity', >'# ISO', '# SEC') > >'dd' displays as the following: > > # Chisq DF Pr(>Chisq) ># Sex 153.0216306 1 7.578366e-35 ># Volume 13.3696538 1 5.114571e-04 ># Weight 0.8476713 1 7.144239e-01 ># Intensity 1.2196050 1 5.388764e-01 ># ISO 2.6349405 1 2.090719e-01 ># SEC 6.0507714 1 2.780045e-02 > >I would like to display it as: > ># Chisq DF Pr(>Chisq) term >153.0216306 1 7.578366e-35 # Sex >13.3696538 1 5.114571e-04 # Volume >0.8476713 1 7.144239e-01 # Weight >1.2196050 1 5.388764e-01 # Intensity >2.6349405 1 2.090719e-01 # ISO >6.0507714 1 2.780045e-02 # SEC > >This is what I came up with > >(cc <- data.frame(data.frame(dd), term=dimnames(dd)[[1]])) > > X..Chisq DF Pr..Chisq. term ># Sex 153.0216306 1 7.578366e-35 # Sex ># Volume 13.3696538 1 5.114571e-04 # Volume ># Weight 0.8476713 1 7.144239e-01 # Weight ># Intensity 1.2196050 1 5.388764e-01 # Intensity ># ISO 2.6349405 1 2.090719e-01 # ISO ># SEC 6.0507714 1 2.780045e-02 # SEC > >But I'm not happy with the following two issues: > >1) How to get rid of the row names? >2) The special characters of #, (, >,) in the column names are not >displayed correctly. > >Any suggestions? > >Thanks, >Gang > > >________________________________ > >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.