Skip to content
Prev 374186 / 398498 Next

Adding a new conditional column to a list of dataframes

On 15/04/2018 7:08 AM, Allaisone 1 wrote:
Your function should return x after modifying it.  As it is, it returns 
the value of x$NewCol [ x[ ,3] <  x[ 1,2] ] <- "C", which is "C".  So 
change it to

MyFunction <- function(x) {
   x$NewCol [ x[ ,3] <  x[ 1,2] ] <- "C"
   x
}

Duncan Murdoch