score:0

The error comes because you are applying max on a dataframe which has mixed datatype (numeric, characters etc). The same error can be reproduced when you apply max on iris.

max(iris)

Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric variables

I think you should apply log2 and max function on one column in the dataframe. For example, if the column name is called col you can do.

result <- lapply(raw, function(x) {
  if(max(x$col) > 100) 
    x$col <- log2(x$col+1)
  x
})

Related Query

More Query from same tag