Hello,
The reason you are only getting one row is because each time you are replacing the NEWMatrix with new output.
Try this:
Oldmatrix<-read.table(text="
?X1??????? X2??????? X3
?22????????? 24??????? 23
?25????????? 27??????? 27
?10????????? 13??????? 15
?",sep="",header=TRUE)
NewMatrix1<-rbind( c("SUM",colSums(Oldmatrix )),c("COUNT",colSums(!is.na(Oldmatrix))))
A.K.
----- Original Message -----
From: Rantony <antony.akkara at ge.com>
To: r-help at r-project.org
Cc:
Sent: Thursday, July 12, 2012 1:22 AM
Subject: [R] Add row into a Matrix witout headers from Function
Hi,
Here i have a matrix like this,
OLDMatrix <-
X1? ? ? ? X2? ? ? ? X3
-----? ? ? ------? ? ------
22? ? ? ? ? 24? ? ? ? 23
25? ? ? ? ? 27? ? ? ? 27
10? ? ? ? ? 13? ? ? ? 15
the thing is,
im running two function(SUM,COUNT) to get output in another matrix called
NEWMatrix
NEWMatrix <- c("SUM",colSums(OLDMatrix ))
NEWMatrix? <- c("COUNT",colSums(!is.na(OLDMatrix )))
Actually i need to get output like this,
NEWMatrix <-
SUM? ? ? 57? ? ? 64? ? ? ? 65
COUNT? 3? ? ? ? 3? ? ? ? ? 3
Instead of getting out put like above, new row getting replaced by new row
of vales.
and after executing the function i getting the values with header. How can i
insert row
of vales into NewMatrix without header. ?
Can anyone please help me ?
Thanks & Regards,
-Antony
--
View this message in context: http://r.789695.n4.nabble.com/Add-row-into-a-Matrix-witout-headers-from-Function-tp4636256.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.