locked
'length.out' must be a non-negative number RRS feed

  • Question

  • Hello!

    I am working on a dataframe, containing numeric and string features. I am doing some very basic computing like finding mean of the column, and percentage. Furthermore, I am trying to generate some pie charts of some selected numeric features, converting them first with as.integer(). But the output is giving error,

    "Error 0063: The following error occurred during evaluation of R script:

    ---------- Start of error message from R ----------
    'length.out' must be a non-negative number


    'length.out' must be a non-negative number
    ----------- End of error message from R -----------
    Start time: UTC 04/23/2016 12:42:41
    End time: UTC 04/23/2016 12:42:54"

    again and again, and cannot figure out where is the error actually is!  

    Moreover, there is no error generating when I am working on RStudio. Please help, if needed, I can share whole thing in github. Here is the code I am trying:

    # Map 1-based optional input ports to variables
    df <- maml.mapInputPort(1) # class: data.frame
    if(nrow(df) >= 3){
    ###############################  Word Cloud #############################
    library(tm)
    library(wordcloud)
    ## Frequent words
    mycorpus <- Corpus(VectorSource(df$message_body))
    myDTM <- TermDocumentMatrix(mycorpus, control = list(minWordLength = 1))
    findFreqTerms(myDTM, lowfreq=10)

    ## WordCloud
    m <- as.matrix(myDTM)
    v <- sort(rowSums(m), decreasing=TRUE)
    myNames <- names(v)
    d <- data.frame(word=myNames, freq=v)
    wordcloud(d$word, d$freq, min.freq=10, random.order = FALSE, max.words = 200, scale= c(3, 1), colors = rainbow(10))

    ##############################################  10 C Emo  ##################################################
    total_emo <- as.integer(c(df[nrow(df),12],df[nrow(df),13], df[nrow(df),14], df[nrow(df),15], df[nrow(df),16], df[nrow(df),17], df[nrow(df),18], df[nrow(df),19], df[nrow(df),20], df[nrow(df),21]))
    tag <- c("ANGER", "ANTICIPATION", "DISGUST", "FEAR", "JOY", "NEGATIVE", "POSITIVE", "SADNESS", "SURPRISE", "TRUST")
    p <- round(total_emo/sum(total_emo)*100)
    tag <- paste(tag, p)
    tag <- paste(tag, "%", sep = "")
    pie(total_emo, labels = tag, col = rainbow(length(tag)), main = "10 Emotion Class")

    ## percentage according to read
    df$perct_according_read <- round((df$Read_By/df$Recipient_Number)*100)
    ## replace "NA" with 0
    df$perct_according_read[is.na(df$perct_according_read)]<-0
    df$perct_according_read <- as.integer(df$perct_according_read)
    barplot(df$perct_according_read,names.arg = df$Sender_Name,ylab = "Percentage According to Read", xlab = "Recipient/s", las = 2,col = "blue", main="Recipients vs Read Graph", border = "red")

    ## average of total read
    df[nrow(df), ncol(df)] <- mean(df$perct_according_read)
    ##############################################################################
    ## percentage according to comment 
    df$people_discussion <- df$Recipient_Number+1
    ## percentage according to activity
    df$active <- round((df$Comment_Number/df$people_discussion)*100)
    df$active[is.na(df$active)]<-0
    df$active <- as.integer(df$active)

    ## Bar Plot
    barplot(df$active, ylab = "Percentage According to Active", xlab = "Recipients Number",col = "blue", main="Activity Bar Plot", border = "red")
    df[nrow(df), ncol(df)] <- mean(df$active)
    ##############################################################################
    df$Liked_By[is.na(df$Liked_By)] <- 0
    df$Liked_By <- as.integer(df$Liked_By)

    df$perct_Like <- round((df$Liked_By/df$people_discussion)*100)
    df$perct_Like[is.na(df$perct_Like)] <- 0
    df$perct_Like <- as.integer(df$perct_Like)
    df[nrow(df), ncol(df)] <- mean(df$perct_Like)
    #################################   Dislike  #################################
    df$Disliked_By[is.na(df$Disliked_By)] <- 0
    df$Disliked_By <- as.integer(df$Disliked_By)

    df$perct_Dislike <- round((df$Disliked_By/df$people_discussion)*100)
    df$perct_Dislike[is.na(df$perct_Dislike)] <- 0
    df$perct_Dislike <- as.integer(df$perct_Dislike)
    df[nrow(df), ncol(df)] <- mean(df$perct_Dislike)

    pt <- as.integer(c(df[nrow(df), (ncol(df)-1)],df[nrow(df), ncol(df)]))
    lbls <- c("Supportive", "Unsupportive")
    pct <- round(pt/sum(pt)*100)
    lbls <- paste(lbls, pct) # add percents to labels 
    lbls <- paste(lbls,"%",sep="") # ad % to labels 
    pie(pt,labels = lbls, col=rainbow(length(lbls)), main="Average: Support and Unsupport")

    # write.csv(df, file = "C:/Users/Wonderland/Downloads/df_old.csv")

    data.set <- df[ ,c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37)]
    data.set <- data.frame(data.set)
    maml.mapOutputPort("data.set");
    } else{
      note <- data.frame(print("The Dataframe is too Small for Calculation or Visualization"))
      colnames(note) <- c("Caution")
      maml.mapOutputPort("note");
    }
    # Select data.frame to be sent to the output Dataset port


    Saturday, April 23, 2016 9:22 AM

Answers

  • well what is seems is that one of the created tables are empty, try to view all the plotted tables before doing so (use print(table))

    Check that all tables that you are trying to plot are not empty...

    Regards

    • Marked as answer by Bipul Mohanto Monday, April 25, 2016 2:03 PM
    Sunday, April 24, 2016 1:15 PM

All replies

  • please copy the output log of your fsiling module for us to understand better the erro and where its happening 

     as you have qquite a few as.numeric

    Regards

    Saturday, April 23, 2016 9:48 AM
  • Sorry, here is the error message so long,

    Error 0063: The following error occurred during evaluation of R script:
    ---------- Start of error message from R ----------
    'length.out' must be a non-negative number


    'length.out' must be a non-negative number
    ----------- End of error message from R -----------
    Start time: UTC 04/23/2016 12:42:41
    End time: UTC 04/23/2016 12:42:54

    Saturday, April 23, 2016 3:01 PM
  • it not what I was thinking of

    if you go on the module that is failing , right click on it click "View Log,"/"OutPut log", click that it will open a log file that contain the execution log of your module the error is probably there with a bit more details 

    Reg

    Saturday, April 23, 2016 5:38 PM
  • Record Starts at UTC 04/23/2016 15:52:55:
    
    Run the job:"/dll "ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run" /Output0 "..\..\Result Dataset\Result Dataset.dataset" /Output1 "..\..\R Device\R Device.dataset"  /dataset1 "..\..\Dataset1\Dataset1.dataset"    /rStreamReader "script.R"  "
    [Start] Program::Main
    [Start]     DataLabModuleDescriptionParser::ParseModuleDescriptionString
    [Stop]     DataLabModuleDescriptionParser::ParseModuleDescriptionString. Duration = 00:00:00.0050733
    [Start]     DllModuleMethod::DllModuleMethod
    [Stop]     DllModuleMethod::DllModuleMethod. Duration = 00:00:00.0000246
    [Start]     DllModuleMethod::Execute
    [Start]         DataLabModuleBinder::BindModuleMethod
    [Verbose]             moduleMethodDescription ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run
    [Verbose]             assemblyFullName ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca
    [Start]             DataLabModuleBinder::LoadModuleAssembly
    [Verbose]                 Loaded moduleAssembly ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca
    [Stop]             DataLabModuleBinder::LoadModuleAssembly. Duration = 00:00:00.0088826
    [Verbose]             moduleTypeName Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript
    [Verbose]             moduleMethodName Run
    [Information]             Module FriendlyName : Execute R Script
    [Information]             Module Release Status : Release
    [Stop]         DataLabModuleBinder::BindModuleMethod. Duration = 00:00:00.0123646
    [Start]         ParameterArgumentBinder::InitializeParameterValues
    [Verbose]             parameterInfos count = 5
    [Verbose]             parameterInfos[0] name = dataset1 , type = Microsoft.Numerics.Data.Local.DataTable
    [Start]             DataTableDatasetHandler::HandleArgumentString
    [Stop]             DataTableDatasetHandler::HandleArgumentString. Duration = 00:00:00.6874986
    [Verbose]             parameterInfos[1] name = dataset2 , type = Microsoft.Numerics.Data.Local.DataTable
    [Verbose]             Set optional parameter dataset2 value to NULL
    [Verbose]             parameterInfos[2] name = bundlePath , type = System.String
    [Verbose]             Set optional parameter bundlePath value to NULL
    [Verbose]             parameterInfos[3] name = rStreamReader , type = System.IO.StreamReader
    [Verbose]             parameterInfos[4] name = seed , type = System.Nullable`1[System.Int32]
    [Verbose]             Set optional parameter seed value to NULL
    [Stop]         ParameterArgumentBinder::InitializeParameterValues. Duration = 00:00:00.7459030
    [Verbose]         Begin invoking method Run ... 
    [ModuleOutput] InputDataStructure
    [ModuleOutput] 
    [ModuleOutput] {
    [ModuleOutput] 	"InputName":Dataset1
    [ModuleOutput] 	"Rows":8
    [ModuleOutput] 	"Cols":32
    [ModuleOutput] 	"ColumnTypes":System.Nullable`1[System.Int32],6,System.String,4,System.Nullable`1[System.Double],1,System.Double,21
    [ModuleOutput] }
    [ModuleOutput] Microsoft Drawbridge Console Host [Version 1.0.2108.0]
    [ModuleOutput] [1] 56000
    [ModuleOutput] 
    [ModuleOutput] Loading objects:
    [ModuleOutput] 
    [ModuleOutput]   port1
    [ModuleOutput] 
    [ModuleOutput] [1] "Loading variable port1..."
    [ModuleOutput] 
    [ModuleOutput] Loading required package: NLP
    [ModuleOutput] 
    [ModuleOutput] Loading required package: RColorBrewer
    [ModuleOutput] 
    [ModuleOutput] Warning messages:
    [ModuleOutput] 
    [ModuleOutput] 1: In as.POSIXlt.POSIXct(Sys.time(), tz = "GMT") :
    [ModuleOutput] 
    [ModuleOutput]   unable to identify current timezone 'C':
    [ModuleOutput] 
    [ModuleOutput] please set environment variable 'TZ'
    [ModuleOutput] 
    [ModuleOutput] 2: In as.POSIXlt.POSIXct(Sys.time(), tz = "GMT") :
    [ModuleOutput] 
    [ModuleOutput]   unknown timezone 'localtime'
    [ModuleOutput] 
    [Stop]     DllModuleMethod::Execute. Duration = 00:00:11.9833508
    [Critical]     Error: Error 0063: The following error occurred during evaluation of R script:
    ---------- Start of error message from R ----------
    'length.out' must be a non-negative number
    
    
    'length.out' must be a non-negative number
    ----------- End of error message from R -----------
    [Critical]     {"InputParameters":{"DataTable":[{"Rows":8,"Columns":32,"estimatedSize":18329600,"ColumnTypes":{"System.Nullable`1[System.Int32]":6,"System.String":4,"System.Nullable`1[System.Double]":1,"System.Double":21},"IsComplete":true,"Statistics":{"0":[8360.1428571428569,8359.0,8335.0,8383.0,16.108264663711932,7.0,1.0],"1":[3,1],"2":[1429253485.7142856,1429401600.0,1427846400.0,1430352000.0,838739.2988459355,6.0,1.0],"3":[7,1],"4":[2.2857142857142856,1.0,0.0,8.0,3.093772546815388,5.0,1.0],"5":[0.0,0.0,0.0,0.0,0.0,1.0,1.0],"6":[0.0,0.0,0.0,0.0,0.0,1.0,1.0],"7":[5.0,5.0,5.0,5.0,0.0,1.0,1.0],"8":[1,1],"9":[3.5714285714285716,4.0,3.0,4.0,0.53452248382484868,2.0,1.0],"10":[7,1],"11":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"12":[1.75,1.5,0.0,7.0,2.3145502494313788,4.0,0.0],"13":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"14":[1.75,0.5,0.0,7.0,2.5495097567963922,5.0,0.0],"15":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"16":[0.5,0.0,0.0,2.0,0.92582009977255142,2.0,0.0],"17":[10.25,5.5,2.0,41.0,12.914554358773449,7.0,0.0],"18":[1.25,0.5,0.0,5.0,1.7525491637693282,4.0,0.0],"19":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"20":[1.25,0.5,0.0,5.0,1.7525491637693282,4.0,0.0],"21":[16.75,9.0,5.0,67.0,21.03568396796263,6.0,0.0],"22":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"23":[14.5,10.5,0.0,40.0,15.638779638176011,6.0,0.0],"24":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"25":[8.375,5.0,0.0,22.0,9.5309645741806062,5.0,0.0],"26":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"27":[1.5,0.0,0.0,9.0,3.2071349029490928,3.0,0.0],"28":[60.375,60.0,33.0,91.0,15.945778662168152,7.0,0.0],"29":[5.875,3.5,0.0,22.0,7.7355856736439623,4.0,0.0],"30":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"31":[0.0,0.0,0.0,0.0,0.0,1.0,0.0]}}],"Unknown":["Key: rStreamReader, ValueType : System.IO.StreamReader"]},"OutputParameters":[],"ModuleType":"ExecuteRScript","ModuleVersion":" Version=6.0.0.0","AdditionalModuleInfo":"ExecuteRScript, Version=6.0.0.0, Culture=neutral, PublicKeyToken=69c3241e6f0468ca;Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript;Run","Errors":"Microsoft.Analytics.Exceptions.ErrorMapping+ModuleException: Error 0063: The following error occurred during evaluation of R script:\r\n---------- Start of error message from R ----------\r\n'length.out' must be a non-negative number\r\n\r\n\r\n'length.out' must be a non-negative number\r\n----------- End of error message from R -----------\r\n   at Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript.ExecuteR(RWorker worker, DataTable dataset1, DataTable dataset2, String bundlePath, StreamReader rStreamReader, Nullable`1 seed) in d:\\_Bld\\8839\\6603\\Sources\\Product\\Source\\Modules\\LanguageWorker\\RSupport\\ExecuteRScript.Dll\\RModule.cs:line 150\r\n   at Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript.RunImpl(DataTable dataset1, DataTable dataset2, String bundlePath, StreamReader rStreamReader, Nullable`1 seed) in d:\\_Bld\\8839\\6603\\Sources\\Product\\Source\\Modules\\LanguageWorker\\RSupport\\ExecuteRScript.Dll\\RModule.cs:line 44\r\n   at Microsoft.MetaAnalytics.RDataSupport.ExecuteRScript.Run(DataTable dataset1, DataTable dataset2, String bundlePath, StreamReader rStreamReader, Nullable`1 seed) in d:\\_Bld\\8839\\6603\\Sources\\Product\\Source\\Modules\\LanguageWorker\\RSupport\\ExecuteRScript.Dll\\RModuleEntryPoint.cs:line 94","Warnings":[],"Duration":"00:00:11.9721104"}
    Module finished after a runtime of 00:00:12.2116817 with exit code -2
    Module failed due to negative exit code of -2
    
    Record Ends at UTC 04/23/2016 15:53:08.
    
    Saturday, April 23, 2016 5:46 PM
  • well what is seems is that one of the created tables are empty, try to view all the plotted tables before doing so (use print(table))

    Check that all tables that you are trying to plot are not empty...

    Regards

    • Marked as answer by Bipul Mohanto Monday, April 25, 2016 2:03 PM
    Sunday, April 24, 2016 1:15 PM
  • thanks, there was some data lack, and found that after your comment. 
    Monday, April 25, 2016 2:04 PM