[R] Calculating proportions from a data frame rather than a table

Rolf Turner r.turner at auckland.ac.nz
Wed Oct 3 23:06:53 CEST 2007


I think that what you need to do is

	as.table(as.matrix(dff))

E.g.

	melvin <- data.frame(x=c(3,1,3,2),y=c(3,3,4,5))
	clyde   <- as.table(as.matrix(melvin))
	prop.table(clyde,1)

           x         y
A 0.5000000 0.5000000
B 0.2500000 0.7500000
C 0.4285714 0.5714286
D 0.2857143 0.7142857

HTH.

			cheers,

				Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}



More information about the R-help mailing list