Re: [R] applying a function to data frame columns

2008-02-22 Thread Henrique Dallazuanna
Try this: sapply(names(u), function(x)u[x][u[x] =min(v[x]) u[x] = max(v[x])]) On 21/02/2008, dxc13 [EMAIL PROTECTED] wrote: useR's, I want to apply this function to the columns of a data frame: u[u = range(v)[1] u = range(v)[2]] where u is the n column data frame under

Re: [R] applying a function to data frame columns

2008-02-22 Thread Tim Hesterberg
You can do: lapply2(u, v, function(u,v) u[inRange(u, range(v))]) using two functions 'lapply2' and 'inRange' defined at bottom. This basically does: lapply(seq(along=u), function(i, U, V){ u - U[[i]] v - V[[i]]

Re: [R] applying a function to data frame columns

2008-02-22 Thread Henrique Dallazuanna
One thing is needed: names(v) - names(u) PS:Thanks Mark Leeds On 22/02/2008, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try this: sapply(names(u), function(x)u[x][u[x] =min(v[x]) u[x] = max(v[x])]) On 21/02/2008, dxc13 [EMAIL PROTECTED] wrote: useR's, I want to apply

[R] applying a function to data frame columns

2008-02-21 Thread dxc13
useR's, I want to apply this function to the columns of a data frame: u[u = range(v)[1] u = range(v)[2]] where u is the n column data frame under consideration and v is a data frame of values with the same number of columns as u. For example, v1 - c(1,2,3) v2 - c(3,4,5) v3 - c(2,3,4) v -