Skip to content
Prev 261906 / 398503 Next

modify a data frame by values in the columns

On 2011-06-03 13:34, Jason024 wrote:
This seems made for within(); calling your data.frame 'd':

  d.new <- within(d, {
                      col1 <- ifelse(col1 < 12, -1, col1)
                      col2 <- ifelse(col2 > 10, -1, col2)
                     })


Peter Ehlers