Shot in the dark: from
is a function, not a numeric value. If so, then it's also likely:
- This error bubbled up from inside other functions, so
from
isn't a variable name you've assigned.
- At some point in your code, you reference a value that does not exist, but there is a function of the same name.
- You sometimes reuse names of functions for other values.
If #3 is true, the best advice is to use unique names for variables. Otherwise, situations like this will keep happening. This can lead to long debugging sessions because the problem is in the names, not the language.
Just for clarity, here's an example of how unique names can help:
## confusing error message ----
library(data.table)
DT <- data.table(x = c("a", "a", "b", "b"), y = 1:4)
DT2 <- DT[, list(mean = mean(y)), by = x]
DT2
# x mean
# 1: a 1.5
# 2: b 3.5
DT2[, mean := NULL]
DT2[, is.finite(mean)]
# Error in is.finite(mean) :
# default method not implemented for type 'closure'
## sane error message ----
DT3 <- DT[, list(mean_y = mean(y)), by = x]
DT3
# x mean_y
# 1: a 1.5
# 2: b 3.5
DT3[, mean_y := NULL]
DT3[, is.finite(mean_y)]
# Error in eval(jsub, SDenv, parent.frame()) : object 'mean_y' not found```