[R] Correct use of ddply with own function

2012-05-05 Thread Johannes Radinger
Hi, I am really confused how ddply work, so maybe you can help me. I created a function that sorts a vector etc. fn - function(x){ x1 - sort(x) x2 - seq(length(x)) x3 - x2/max(x2) df - data.frame(x1,x2,x3) df } Probably this is not the best form of the

Re: [R] Correct use of ddply with own function

2012-05-05 Thread Tal Galili
Hi Johannes , Try this: var1 - rep(c(a,b),c(100,100)) var2 - runif(200,1,50) df.test - data.frame(var1,var2) fn - function(x){ x - x$var2 x1 - sort(x) x2 - seq(length(x)) x3 - x2/max(x2) df - data.frame(x1,x2,x3) df } require(plyr)