I donβt think you are missing something. You should probably point out an error here when referring to this entry. Good catch!
This is because when you use lapply with .SD (in j ), data.table tries to find if there is a way to optimize overhead due to function calls, if possible. However, in this process, instead of calling a function:
..FUN(Sepal.Length)
where ..FUN = function(x) sum(!is.na(x), na.rm=TRUE) , it becomes:
..FUN(FUN = Sepal.Length)
Since the function does not have an argument called FUN , it returns an error. You can verify this by changing x to FUN in a function call:
dt[, lapply(.SD, FUN=function(FUN) sum(!is.na(FUN), na.rm=TRUE)), by = Species] # Species Sepal.Length Sepal.Width Petal.Length Petal.Width # 1: setosa 49 50 50 50 # 2: versicolor 44 50 50 50 # 3: virginica 47 50 50 50
Inside: if you look at the function [.data.table , one way to fix this is to rewrite the line:
txt <- as.list(jsub)[-1L]
from:
txt <- as.list(jsub)[-1L] names(txt)[2] <- ""
Starting CHECK completed successfully.
Arun
source share