Re: [R] Applying a function to dataframe column where the function value depends on the value of another column

2020-06-05 Thread Jeff Newmiller
Press send too soon? This is not actually a question. Do read the Posting Guide... for one thing you need to post in plain text because the automatic text conversion tends to mess up what you send if it is HTML. On June 5, 2020 12:02:44 AM PDT, TJUN KIAT TEO wrote: >Suppose I have a dataframe

[R] Applying a function to dataframe column where the function value depends on the value of another column

2020-06-05 Thread TJUN KIAT TEO
Suppose I have a dataframe in this from a b c g 2 3 h 4 5 i 6 7 I want to apply a function to individual elements of column C where the function value depends on the value of column A [[alternative HTML version deleted]] __ R-help@r-project.o

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-17 Thread David Winsemius
s A&M University > College Station, TX 77840-4352 > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller > Sent: Wednesday, December 16, 2015 7:01 PM > To: Matteo Richiardi; r-help@r-project.org > Subject: Re: [R]

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-17 Thread David L Carlson
f Newmiller Sent: Wednesday, December 16, 2015 7:01 PM To: Matteo Richiardi; r-help@r-project.org Subject: Re: [R] Applying a function to a matrix using indexes as arguments Would outer( A, B, `*` ) / C do the trick for you? -- Sent from my phone. Please excuse my brevity. On December 16,

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-17 Thread Matteo Richiardi
Hi David, that's a great answer, thanks so much. I imagined apply() was involved in the solution, but I was unable to find how myself. Thanks again. Matteo On 17 December 2015 at 01:37, David Winsemius wrote: > > > On Dec 16, 2015, at 5:34 PM, David Winsemius > wrote: > > > > > >> On Dec 16, 20

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread David Winsemius
> On Dec 16, 2015, at 5:34 PM, David Winsemius wrote: > > >> On Dec 16, 2015, at 4:18 PM, Matteo Richiardi >> wrote: >> >> I have to evolve each element of a matrix W >> >> W <- matrix(0,2,3) >> >> according to some function which uses the indices of the matrix [i,j] as >> arguments: >> w.

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread David Winsemius
> On Dec 16, 2015, at 4:18 PM, Matteo Richiardi > wrote: > > I have to evolve each element of a matrix W > > W <- matrix(0,2,3) > > according to some function which uses the indices of the matrix [i,j] as > arguments: > w.fun = function(i,j) { > return A[i]*B[j]/(C[i,j]) > } > > where > A<-

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread Jeff Newmiller
Would outer( A, B, `*` ) / C do the trick for you? -- Sent from my phone. Please excuse my brevity. On December 16, 2015 4:41:13 PM PST, Matteo Richiardi wrote: >My problem is of course more complicated, and is obviously not a >homework. >I just wanted to provide a minimal working example. Y

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread Matteo Richiardi
My problem is of course more complicated, and is obviously not a homework. I just wanted to provide a minimal working example. You can replace the matrix C with a matrix containing any number, for what matters. Btw, because numbers are extracted from a Gaussian distribution, the likelihood that you

Re: [R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread Jeff Newmiller
This calculation divides by values centered around zero. The only context that I can think of that would require such silliness is a homework problem, and this list has a no-homework policy. If not, then mentioning the theory you are applying might help someone point you at an existing function

[R] Applying a function to a matrix using indexes as arguments

2015-12-16 Thread Matteo Richiardi
I have to evolve each element of a matrix W W <- matrix(0,2,3) according to some function which uses the indices of the matrix [i,j] as arguments: w.fun = function(i,j) { return A[i]*B[j]/(C[i,j]) } where A<-c(100,100) B<-c(200,200,200) C <- matrix( rnorm(6,mean=0,sd=1), 2, 3) How can I do it

Re: [R] Applying a function to a column of a data frame

2012-06-09 Thread David Winsemius
On Jun 9, 2012, at 1:02 PM, Onur Uncu wrote: Thank you Michael. One follow up question: In the solution using apply(), why are we feeding x[2] inside testfun instead of x[[2]]? Aren't we supposed to feed the vector of values to the function, which is achieved by x[[2]]? `apply` sends the colu

Re: [R] Applying a function to a column of a data frame

2012-06-09 Thread Onur Uncu
Thank you Michael. One follow up question: In the solution using apply(), why are we feeding x[2] inside testfun instead of x[[2]]? Aren't we supposed to feed the vector of values to the function, which is achieved by x[[2]]? Thnks. On Sat, Jun 9, 2012 at 3:38 PM, R. Michael Weylandt wrote: > N

Re: [R] Applying a function to a column of a data frame

2012-06-09 Thread R. Michael Weylandt
No worries -- it's an important question and it introduces you to one of the most important R idioms. [And you get bonus points for having a well formed question!] You're probably looking for something like this: apply(testframe, 1, function(x) testfun(x[2])) Which goes row-by-row and substitute

[R] Applying a function to a column of a data frame

2012-06-09 Thread Onur Uncu
Apologees the novice question. Currently climbing up the learning curve of R. Suppose I have the following function and the data.frame: testfun<-function(x=1,y=2) x+y testframe=data.frame(col1=c(1,2),col2=c(3,4)) When evaluating testfun, I want to use the default value for y (which is 2) and fo

Re: [R] Applying a function to categorized data?

2012-04-13 Thread Robert Latest
Hello Steve, thank you for your reply. You're right, just before I read your post I'd found aggregate() and indeed it brought me a long way towards my goal. I've been a C programmer for 20+ years, and I'm fairly firm in SQL, so to understand R I need to lose my scalar and row (record) oriented th

Re: [R] Applying a function to categorized data?

2012-04-12 Thread R. Michael Weylandt
You can also get the official getting started tutorial by typing help.start() at the command prompt. Michael On Thu, Apr 12, 2012 at 2:52 PM, steven mosher wrote: >  Welcome to R and the list. > >  Others may suggest books ( Nutshell was my first ) but first there are > some things that will h

Re: [R] Applying a function to categorized data?

2012-04-12 Thread steven mosher
Welcome to R and the list. Others may suggest books ( Nutshell was my first ) but first there are some things that will help you both in programming and getting help on the list. You should post executable code in your question. So, build a toy example of the data.frame you have and show what

[R] Applying a function to categorized data?

2012-04-12 Thread Robert Latest
Hi all, I'm just getting started in R. My problem is the following: I have a data frame (v1) with lots of production data measurements. Each row contains a single measurement ('ARI_MIT') with a timestamp. I want to "lump" the data by months with their mean and standard deviation. I have already

Re: [R] applying a function in list of indexed elements of a vector:

2012-03-10 Thread R. Michael Weylandt
Your code for iy doesn't work as providedI'll assume you meant this instead: iy <- list(c(1, 2),c(1, 2), c(1, 2, 3, 4), c(2, 3, 5), c(4), c(5, 6, 7), c(7, 8, 9)) Then sapply(iy, function(x) sum(Y1[x])) Michael On Sat, Mar 10, 2012 at 5:01 PM, aldi wrote: > Hi, > > I have a vector > Y1 <-c

[R] applying a function in list of indexed elements of a vector:

2012-03-10 Thread aldi
Hi, I have a vector Y1 <-c(8, 11, 7, 5, 6, 3, 6, 3, 3) and an index iy <-c(c(1, 2),c(1 2), c(1, 2, 3, 4), c(2, 3, 5), c(4), c(5, 6, 7), c(7, 8, 9)) how can I produce the mean, or the sum of the elements specified in the index iy from the vector Y1? expecting something like this for th

Re: [R] Applying a function

2011-12-23 Thread Rui Barradas
Sorry, in the function body, NO 'tab1', use 'x' only: recovery.rate <- function(x) unlist(lapply(split(x, x[,2]), function(x) mean(x[[4]]=="y"))) The error is because 'tab1' existed in the environment and the function would find it. This time, tested after removing 'tab1'. Rui Barradas -- Vi

Re: [R] Applying a function

2011-12-23 Thread Rui Barradas
Joanie Van De Walle wrote > > Hi, > >I need help writing a function > >I capture seal pups mutliple times during the lactation season in order > to >monitor their growth rate. When I release them, the recovery > (mother-pup) >time is not the same for all individuals. I want to k

Re: [R] Applying a function

2011-12-23 Thread Steinar Veka
First, it may be a good idea to use 1 for “yes” and 0 for “no” in the motherrecovery column. Then if you name your table e.g tab1, you may try something like this.. sum(tab1[,2]==1*tab1[,4])/sum(tab1[,2]==1) 2011/12/23 Joanie Van De Walle > > Hi, > > I need help writing a function

[R] Applying a function

2011-12-23 Thread Joanie Van De Walle
Hi, I need help writing a function I capture seal pups mutliple times during the lactation season in order to monitor their growth rate. When I release them, the recovery (mother-pup) time is not the same for all individuals. I want to know if individuals that recover their mot

Re: [R] Applying a function to a subset

2011-05-29 Thread gaiarrido
That's it. thanks very much, I save hours if work qith your reply - Mario Garrido Escudero PhD student Dpto. de Biología Animal, Ecología, Parasitología, Edafología y Qca. Agrícola Universidad de Salamanca -- View this message in context: http://r.789695.n4.nabble.com/Applying-a-function-to-a

Re: [R] Applying a function to a subset

2011-05-29 Thread Stephan Kolassa
Or just include is.na=TRUE in the definition of kurtosis(): kurtosis<-function(x) { m4<-sum((x-mean(x,na.rm=TRUE))^4,na.rm=TRUE)/length(x) s4<-var(x,na.rm=TRUE)^2 m4/s4 - 3 } HTH Stephan Am 29.05.2011 11:34, schrieb Jim Holtman: kurtosis(fem[!is.na(fem)]) Sent from my iPad On May 29,

Re: [R] Applying a function to a subset

2011-05-29 Thread Jim Holtman
kurtosis(fem[!is.na(fem)]) Sent from my iPad On May 29, 2011, at 4:54, gaiarrido wrote: > Here´s my problem, > i have developed the function kurtosis (using R-book as a guide) with this > commands: > kurtosis<-function(x) { > m4<-sum((x-mean(x))^4)/length(x) > s4<-var(x)^2 > m4/s4 - 3 } > > Th

[R] Applying a function to a subset

2011-05-29 Thread gaiarrido
Here´s my problem, i have developed the function kurtosis (using R-book as a guide) with this commands: kurtosis<-function(x) { m4<-sum((x-mean(x))^4)/length(x) s4<-var(x)^2 m4/s4 - 3 } Then create the object fem, which is the difference between the count of a trait in the left side of the body mi

Re: [R] applying a function over a matrix 2N x M to produce a matrix N x M

2011-04-22 Thread David Winsemius
On Apr 22, 2011, at 2:38 PM, Richard M. Heiberger wrote: I like David's answer and it can be made much faster. I show three refinements, each faster than the preceding one. Rich > system.time(for (i in 1:1000) + mat[seq(1, nrow(mat), by=2), ]+mat[seq(2, nrow(mat), by=2), ] + ) user syst

Re: [R] applying a function over a matrix 2N x M to produce a matrix N x M

2011-04-22 Thread Richard M. Heiberger
I like David's answer and it can be made much faster. I show three refinements, each faster than the preceding one. Rich > system.time(for (i in 1:1000) + mat[seq(1, nrow(mat), by=2), ]+mat[seq(2, nrow(mat), by=2), ] + ) user system elapsed 0.180.000.19 > > system.time(for (i in

Re: [R] applying a function over a matrix 2N x M to produce a matrix N x M

2011-04-22 Thread David Winsemius
On Apr 22, 2011, at 12:13 PM, Christine SINOQUET wrote: Hello, mat1 only consists of 0s and 1s: 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 1 N = 3 M = 6 I would like to "compress" mat1 every two rows, applying summation over the two rows (per column), at each ste

[R] applying a function over a matrix 2N x M to produce a matrix N x M

2011-04-22 Thread Christine SINOQUET
Hello, mat1 only consists of 0s and 1s: 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 1 N = 3 M = 6 I would like to "compress" mat1 every two rows, applying summation over the two rows (per column), at each step, to yield: mat2 1 1 1 1 1 0 1 2 2 0 1 1 1 1 0 2 0 1 The

[R] applying a function to output a matrix

2011-01-25 Thread Lara Poplarski
Dear List, I am using function distCosine from package geosphere to a list of lat/lon coordinates, and I want to calculate the great circle distance between a pair of coordinates in the list and all other pairs --- essentially, the output should be a matrix. I have been able to achieve this with t

Re: [R] Applying a function on each columns of a matrix

2010-01-29 Thread Henrique Dallazuanna
A example: set.seed(123) m <- matrix(rnorm(12), 3) myParam <- rowMeans(m) sweep(m, 1, myParam, FUN = "-") This subtracts the myParam value in each column. On Fri, Jan 29, 2010 at 6:59 PM, anna wrote: > > I had a quick look at the sweep function but didn't find a solution in it, I > am going to

Re: [R] Applying a function on each columns of a matrix

2010-01-29 Thread anna
I had a quick look at the sweep function but didn't find a solution in it, I am going to look at it again then. - Anna Lippel -- View this message in context: http://n4.nabble.com/Applying-a-function-on-each-columns-of-a-matrix-tp1415660p1428193.html Sent from the R help mailing list archiv

Re: [R] Applying a function on each columns of a matrix

2010-01-29 Thread Henrique Dallazuanna
See sweep function On Fri, Jan 29, 2010 at 2:32 PM, anna wrote: > > Hello everyone, I have the following matrix >             [,1]          [,2]          [,3]         [,4] >  [1,]  0.002809706  0.0063856960  0.0063856960  0.011749681 >  [2,]  0.004893124  0.0023118418 -0.0005122951 -0.014646465 >

Re: [R] Applying a function on each columns of a matrix

2010-01-29 Thread anna
But then I would have to make a loop right? - Anna Lippel -- View this message in context: http://n4.nabble.com/Applying-a-function-on-each-columns-of-a-matrix-tp1415660p1415743.html Sent from the R help mailing list archive at Nabble.com. __ R-h

Re: [R] Applying a function on each columns of a matrix

2010-01-29 Thread Carlos J. Gil Bellosta
Hello, You could do something along the following lines: sapply( 1:ncol( my.matrix ), function( i ) my.foo( my.matrix[,i], my.parm[i] ) Best regards, Carlos J. Gil Bellosta http://www.datanalytics.com anna wrote: Hello everyone, I have the following matrix

[R] Applying a function on each columns of a matrix

2010-01-29 Thread anna
Hello everyone, I have the following matrix [,1] [,2] [,3] [,4] [1,] 0.002809706 0.0063856960 0.0063856960 0.011749681 [2,] 0.004893124 0.0023118418 -0.0005122951 -0.014646465 [3,] 0.003547897 0.0063355297 0.0030410542 0.011403953 [4,] 0.004838

Re: [R] Applying a function on n nearest neighbours

2009-10-30 Thread Karl Ove Hufthammer
On Fri, 30 Oct 2009 10:28:49 +0100 Karl Ove Hufthammer wrote: > $ (pos=which(order(abs(iris$Sepal.Length-x)) %in% 2:6)) This should of course be: (pos=order(abs(iris$Sepal.Length-x))[2:6]) -- Karl Ove Hufthammer __ R-help@r-project.org mailing list

[R] Applying a function on n nearest neighbours

2009-10-30 Thread Karl Ove Hufthammer
I'm having a problem where I have to apply a function to a subset of a variable, where the subset is defined by the n nearest neighbours of a second variable. Here's an example applied to the 'iris' dataset: $ head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1

Re: [R] applying a function to a pair of components for each row of a list

2009-06-27 Thread Kavitha Venkatesan
Milton, Thanks, the answer was in fact as simple as you pointed out. I was thinking more complicated than needed! Kavitha On Sun, Jun 28, 2009 at 1:11 AM, milton ruser wrote: > Hi Kavitha, > > I must confess you that I not understood well what you are looking for. > But.. > > mylist<-list(x=1:2

Re: [R] applying a function to a pair of components for each row of a list

2009-06-27 Thread milton ruser
Hi Kavitha, I must confess you that I not understood well what you are looking for. But.. mylist<-list(x=1:25, y=runif(n=25)) plot(mylist, type="n") points(mylist, type="p", col=mylist$x) Hth, miltinho On Sun, Jun 28, 2009 at 1:03 AM, Kavitha Venkatesan < kavitha.venkate...@gmail.com> wrote:

[R] applying a function to a pair of components for each row of a list

2009-06-27 Thread Kavitha Venkatesan
Hi, I have a set of (x,y) coordinate pairs that are stored as a list > my_list $x [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 $y [1] -8.0866819 -7.3876052 -6.6849311 -5.9837693 -5.2967432 -4.6525466 [7] -4.0999453 -3.6556190 -3.3076102 -3.0360780 -2.8220465

Re: [R] Applying a function to a dataframe

2008-12-16 Thread David Winsemius
On Dec 16, 2008, at 6:00 PM, glenn roberts wrote: Another Newbie Question sorry: I am trying to apply a function a dataframe and could use some help: Assuming, dim(df) = (10,2) say, I would like to apply a function that looks at each row in turn and returns a list (dim =(10,1)) using the

[R] Applying a function to a dataframe

2008-12-16 Thread glenn roberts
Another Newbie Question sorry: I am trying to apply a function a dataframe and could use some help: Assuming, dim(df) = (10,2) say, I would like to apply a function that looks at each row in turn and returns a list (dim =(10,1)) using the columns as inputs to the function, but with no INDEX stuf

[R] applying a function several times

2008-12-05 Thread Carlos Cuartas
I am sorry. I am not sure if the mail a send before to this list was rejected because of header (subject). I've changed it. The first maybe was not appropriate. I did a function (sec_conop) whose arguments are syndic, well and wellconop. sec_conop(syndic='01syndic.txt',well='well-1.csv',wellcon

[R] applying a function to another function

2008-12-03 Thread Carlos Cuartas
Hello, I did a function (sec_conop) whose arguments are syndic, well and wellconop. sec_conop(syndic='01syndic.txt',well='well-1.csv',wellconop='well-1.dat');closeAllConnections() This function takes “well” and “syndic”, matching between them and then it does some transformations. The result i

Re: [R] Applying a function to a list of arguments ...

2008-11-07 Thread Gabor Grothendieck
Try this: func <- function(f, ...) f(...) # e.g. func(sin, 0) # same as sin(0) func(max, 1, 2) # same as max(1, 2) On Fri, Nov 7, 2008 at 5:21 AM, <[EMAIL PROTECTED]> wrote: > How can I apply function f, that I get as an argument as in > > func <- function(f, ...) { > . > . > . > } > > to a lis

Re: [R] Applying a function to a list of arguments ...

2008-11-07 Thread Duncan Murdoch
On 11/7/2008 5:40 AM, baptiste auguie wrote: perhaps something like, func <- function(f, ...) { do.call(f, ...) } func(rnorm, list(n=3, mean=2, sd=3)) Alternatively, if the caller doesn't want to put the args in a list, your func can do it: func2 <- function(f, ...) { do.call(f, list(..

Re: [R] Applying a function to a list of arguments ...

2008-11-07 Thread baptiste auguie
perhaps something like, func <- function(f, ...) { do.call(f, ...) } func(rnorm, list(n=3, mean=2, sd=3)) baptiste On 7 Nov 2008, at 10:21, [EMAIL PROTECTED] wrote: How can I apply function f, that I get as an argument as in func <- function(f, ...) { . . . } to a list of arguments list

[R] Applying a function to a list of arguments ...

2008-11-07 Thread roby . brunelli
How can I apply function f, that I get as an argument as in func <- function(f, ...) { . . . } to a list of arguments list(a, b, c) (eg the ... argument of func above) in order to obtain f(a, b, c) Thanks a lot, Roberto [[alternative HTML version deleted]] ___

Re: [R] applying a function recursively

2008-06-12 Thread Gabor Grothendieck
Wrap each element in an environment, flatten that and then extact the element in each environment. (Be sure not to use an old version of R since sufficiently far back R had a bug when environments were stored in lists that was since fixed.) L <- rapply(test.list, function(el) environment(), how =

Re: [R] applying a function recursively

2008-06-12 Thread Jim Lemon
Prof Brian Ripley wrote: > > See ?rapply Golly, the things one learns when least expecting it. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guid

Re: [R] applying a function recursively

2008-06-12 Thread Georg Otto
Hi, thanks a lot for your help. Somehow rapply had escaped my notice. I also have a follow-up question on that. I would like to "flatten" my output list to a list with only one level. Option "unlist" in rapply returns a character vector, in my example: > rapply(test.list, rev, how="unlist")

Re: [R] applying a function recursively

2008-06-12 Thread Jim Lemon
Georg Otto wrote: Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: ... I understand that with a fixed number of recursion levels one can use lapply() in a nested way, but what i

Re: [R] applying a function recursively

2008-06-11 Thread Marc Schwartz
on 06/11/2008 10:51 AM Georg Otto wrote: Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"), "C"=c("g", "h", "i"

Re: [R] applying a function recursively

2008-06-11 Thread Charles C. Berry
See ?rapply for your example rapply( test.list, rev, how='replace' ) HTH, Chuck On Wed, 11 Jun 2008, Georg Otto wrote: Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of

Re: [R] applying a function recursively

2008-06-11 Thread Prof Brian Ripley
See ?rapply On Wed, 11 Jun 2008, Georg Otto wrote: Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"), "C"=c("

[R] applying a function recursively

2008-06-11 Thread Georg Otto
Hi, I have a question about applying a function recursively through a list. Suppose I have a list where the different elements have different levels of recursion: > test.list<-list("I"=list("A"=c("a", "b", "c"), "B"=c("d", "e", "f"), > "C"=c("g", "h", "i")), + "II"=list("A"=lis

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

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]] u

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 und

[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