Displaying 1 result from an estimated 1 matches for "whichmin".
2013 Jan 29
4
Fastest way to compare a single value with all values in one column of a data frame
...ow:
y<-data.frame(item="f",a=3,b=10)
y$item<-as.character(y$item)
I have to decide if y$a is larger than the smallest of all the values in
x$a. If it is, I want y to replace the whole row in x that has the lowest
value in column a.
This is how I'd do it.
if(y$a>min(x$a)){
whichmin<-which(x$a==min(x$a))
x[whichmin,]<-y[1,]
}
I am wondering if there is a faster way of doing it. What would be the
fastest possible way? I'd have to do it, unfortunately, many-many times.
Thank you very much!
--
Dimitri Liakhovitski
gfk.com <http://marketfusionanalytics.com/>...