An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120917/1c451f81/attachment.pl>
How to divide each column with its own value
5 messages · s.s.m. fauzi, Daniel Malter, Jha, Ashutosh Kumar +1 more
It's not quite clear what you want to do. Is it just this? a<-c(1,2,3,4) dim(a)<-c(2,2) a/a This gives the element by element ratio. HTH, Daniel shukor wrote
Hi,
I have a matrix as below:
mat=
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
What I want to do is, I would like to divide each column with its own
value, in order to get value 1.
Is there any simple script for that?
[[alternative HTML version deleted]]
______________________________________________ R-help@ 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.
-- View this message in context: http://r.789695.n4.nabble.com/How-to-divide-each-column-with-its-own-value-tp4643335p4643336.html Sent from the R help mailing list archive at Nabble.com.
On 17-09-2012, at 06:50, s.s.m. fauzi wrote:
Hi,
I have a matrix as below:
mat=
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
What I want to do is, I would like to divide each column with its own
value, in order to get value 1.
Is there any simple script for that?
mat/mat Berend
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120917/53dba203/attachment.pl>
On 17-09-2012, at 07:31, Jha, Ashutosh Kumar wrote:
Dear Berend, No need to devide what all you need a indentity matrix with same dimesion. Following is one way to achieve this. mat<-matrix(1,ncol=ncol(mat),nrow=nrow(mat)).
That is not an identity matrix. It is a matrix with all elements equal to 1. An identity matrix has 1 on the diagonal and 0 elsewhere and is created by diag(..) The OP asked about divide and the answer I gave was geared to that specific question. Of course if the result is a constant value for all elements a simple matrix(...) will also do. Berend
Regards Ashutosh On Monday, 17-09-2012 on 10:58 Berend Hasselman wrote: On 17-09-2012, at 06:50, s.s.m. fauzi wrote:
Hi,
I have a matrix as below:
mat=
[,1] [,2] [,3]
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
What I want to do is, I would like to divide each column with its own
value, in order to get value 1.
Is there any simple script for that?
mat/mat Berend
______________________________________________ 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.