Search code examples
rlapplyazure-machine-learning-service

invalid subscript type 'list' Azure Machine Learning


PROBLEM

I deployed my experiments in Azure Machine Learning as a Web Service. The experiments ran without error.

But when testing using REQUEST/RESPONSE, I'm getting the error below:

Execute R Script Piped (RPackage) : The following error occurred during evaluation of R script: R_tryEval: return error: Error in split(df, list(df$PRO_NAME, df$Illness_Code))[Ind] : invalid subscript type 'list'

This is the code:

# Loop through the dataframe and apply model
Ind <- sapply(split(df, list(df$PRO_NAME,df$Illness_Code)), 
              function(x)nrow(x)>1)

out <- lapply(
    split(df, list(df$PRO_NAME, df$Illness_Code))[Ind],
    function(c){
        m <- lm(formula = COUNT ~ YEAR, data = c)
        coef(m)
    })

Solution

  • FIXED

    Problem:

    Some R codes don't work if input data is limited (e.g 1-2 rows only)

    Solution:

    Load data by Batch instead of REQUEST/RESPONSE