“no such index at level 1” error for a specific scenario when trying to use data.table programmatically
问题 The Problem I wrote a function to use data.table programmatically. The function is as follows transformVariables4 <- function(df_1n_data, c_1n_variablesToTransform, c_1n_newVariableNames, f_01_functionToTransform, ...) { for (i in 1:length(c_1n_variablesToTransform)) { df_1n_data[, c(c_1n_newVariableNames[i]) := list(forceAndCall(n = 1, FUN = f_01_functionToTransform, df_1n_data[[c_1n_variablesToTransform[i]]], ...))] } return(df_1n_data) } The function works fine for this scenario df <- data