[R] How to divide each column with its own value

Daniel Malter daniel at umd.edu
Mon Sep 17 07:11:11 CEST 2012


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.




More information about the R-help mailing list