cancel
Showing results for 
Search instead for 
Did you mean: 

Execution of R script failed.;Timeout during R script execution or receiving result data undefined

Former Member
0 Kudos

Hi all I have the above error when I try to execute the following R script within Expert Analytics, which is connected to an Hana Server.

Did I miss something?

cannonballs <- function(cannons) {


  # VARIABLES FOR ITERATION CREATION
  diversi_anni = unique(cannons$anno)
  diversi_mesi = unique(cannons$mese)
  diversi_gg = unique(cannons$giorno)
  diverse_ore = unique(cannons$ora)
  
  # CREATION OF FINAL DATA STRUCTURE
  cannoni_output <- data.frame(
    PONumber=double(),
    id=double(),
    temp=double(),
    umi=double(),
    anno=double(),
    mese=double(),
    giorno=double(),
    ora=double(),
    latitude=double(),
    longitude=double(),
    cluster=double()
  )
  
  # FOR EACH HOUR OF EACH DAY OF EACH MONTH OF EACH YEAR
library(dynamicTreeCut)
  
  for(year in diversi_anni){
    for(month in diversi_mesi){
      for(day in diversi_gg){
        for(hour in diverse_ore){
          # SUBSET DATA
          sub_ora = subset(cannons, cannons$ora == hour & cannons$giorno == day & cannons$mese == month & cannons$anno == year)
          
          if(nrow(sub_ora)>=3){
            # DATA CLEANING FOR CLUSTERING
            var_clust = sub_ora
            var_clust$id=NULL
            var_clust$ora=NULL
            var_clust$giorno=NULL
            var_clust$mese=NULL
            var_clust$anno=NULL
            var_clust$PONumber=NULL
            var_clust$latitude=NULL
            var_clust$longitude=NULL
            var_clust$umi = scale(var_clust$umi)
            var_clust$temp = scale(var_clust$temp)
            if(is.nan(var_clust$umi)){var_clust$umi=sub_ora$umi}
            if(is.nan(var_clust$temp)){var_clust$umi=sub_ora$temp}
            
            # DISTANCE CALCULATION
            d = dist(var_clust)
            
            # HIERARCHICAL CLUSTERING
            c = hclust(d, method="ward.D2")
            
            # TREE CUTTING
            members = cutreeDynamicTree(c, maxTreeHeight = 5, minModuleSize = 2 )
            #members = cutree(c, k = 2)
            sub_ora$cluster = members
            cannoni_output = rbind(cannoni_output, sub_ora)
          } 
        }
      }
    }
  }


  return(list(out=cannoni_output))
  
};

Accepted Solutions (0)

Answers (4)

Answers (4)

achab
Product and Topic Expert
Product and Topic Expert
0 Kudos

smoruz were you able to resolve your problem? Kind regards Antoine Chabert

achab
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dumitru, Andreas means that Expert Analytics connects to a local file, instead of connecting to SAP HANA. Kind regards, Antoine

Former Member
0 Kudos

Hi Andreas,

thank you for your kind reply. The code is working on a local file, but it doesn't on Hana.

What do you mean by Expert mode?

AndreasForster
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dumitru,

Did you specify in the R extension the columns (name and data type) your extension is outputting?

In order to reduce complexity and to narrow the problem down, I find it helpful test the R extension in Expert mode connecting to a local file first. Once that is working, I suggest to move to HANA.

Many Greetings

Andreas