[R] Finding the position of a variable in a data.frame

Gerald Jansen gerald.jansen at newpage.ca
Thu Aug 3 00:53:02 CEST 2006


On Wed, 02 Aug 2006 17:12:53 -0400, Chuck Cleland wrote:
> Why not do it this way?
> 
> Df$bat <- replace(Df$bat, Df$bat >=50, 100)

Is that any different, performancewise, than the following?

Df$bat[Df$bat >= 50] <- 100

Gerald Jansen


...
John Kane wrote:
> Simple example
> 
> cat <- c( 3,5,6,8,0)
> dog <- c(3,5,3,6, 0)
> rat <- c (5, 5, 4, 9, 0)
> bat <- c( 12, 42, 45, 32, 54)
> 
> Df <- data.frame(cbind(cat, dog, rat, bat))
...



More information about the R-help mailing list