Skip to content

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
--
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:

            
mat/mat

Berend
#
On 17-09-2012, at 07:31, Jha, Ashutosh Kumar wrote:

            
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