locked
RPackage library exception: Failed to convert RObject to DataSet. ( Error 1000 ) RRS feed

  • Question

  • Hi!

    I get this error during the execution of an R script (below), that simply takes two data frames as inputs, extracts one column from each of them, and combines the two columns into a data frame. The variable 'output' is a data frame, and I am able to successfully print it out and see it in the output log. Any help would be appreciated!

    --- Start of R script ---

    # Map 1-based optional input ports to variables
    predictions1 <- maml.mapInputPort(1)
    predictions2 <- maml.mapInputPort(2)

    output <- data.frame(AvgTaskMins_Pred = predictions1[, 'Scored Label Mean'], DaysToComplete_Pred = predictions2[, 'Scored Label Mean'])
    print(output)

    # Select data.frame to be sent to the output Dataset port
    maml.mapOutputPort("output")

    -- End of R script ---

    If I comment out "maml.mapOutputPort("output")" line, the script executes fine.

    Here is some more info on the error, as given in the output log:

    "[Stop]     DllModuleMethod::Execute. Duration = 00:00:11.0169079
    [Critical]     Error: Error 1000: RPackage library exception: Failed to convert RObject to DataSet
    [Critical]     {"InputParameters":{"DataTable":[{"Rows":1467,"Columns":35,"estimatedSize":20840448,"ColumnTypes":{"System.Int32":25,"System.String":8,"System.Double":2},"IsComplete":true,"Statistics":{"0":[24.955010224948875,17.0,1.0,210.0,23.084680560619493,116.0,0.0],"1":[29,0],"2":[90,0],"3":[9,0],"4":[3,0],"5":[0.5426039536468984,1.0,0.0,1.0,0.49835147944483943,2.0,0.0],"6":[0.69870483980913434,1.0,0.0,1.0,0.45897710815329817,2.0,0.0],"7":[152,0],"8":[143,0],"9":[18,0],"10":[3,0],"11":[1.0763462849352421,1.0,1.0,3.0,0.26819747983619469,3.0,0.0],"12":[457.25426039536467,240.0,0.0,7116.0,821.35214200357211,374.0,0.0],"13":[4.6353101567825492,6.0,1.0,7.0,2.0118833414803348,7.0,0.0],"14":[0.77914110429447858,1.0,0.0,1.0,0.41496701638465033,2.0,0.0],"15":[0.75187457396046353,1.0,0.0,1.0,0.43207228132608194,2.0,0.0],"16":[0.67075664621676889,1.0,0.0,1.0,0.47009872415488591,2.0,0.0],"17":[0.74710293115201087,1.0,0.0,1.0,0.43482067892665488,2.0,0.0],"18":[0.76209952283571913,1.0,0.0,1.0,0.42594308610269283,2.0,0.0],"19":[0.91683708248125428,1.0,0.0,1.0,0.27622247699244651,2.0,0.0],"20":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"21":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"22":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"23":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"24":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"25":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"26":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"27":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"28":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"29":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"30":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"31":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"32":[1.21813224267212,1.0,1.0,3.0,0.47888405004417572,3.0,0.0],"33":[10.234751582928352,8.8941780118251916,2.1702554039820119,35.81376896251372,5.5857982721794741,1465.0,0.0],"34":[4.614416752652601,4.0584498356879868,0.65202962052014746,20.376511517945396,2.914055050449627,1465.0,0.0]}},{"Rows":1467,"Columns":35,"estimatedSize":4190208,"ColumnTypes":{"System.Int32":25,"System.String":8,"System.Double":2},"IsComplete":true,"Statistics":{"0":[24.955010224948875,17.0,1.0,210.0,23.084680560619493,116.0,0.0],"1":[29,0],"2":[90,0],"3":[9,0],"4":[3,0],"5":[0.5426039536468984,1.0,0.0,1.0,0.49835147944483943,2.0,0.0],"6":[0.69870483980913434,1.0,0.0,1.0,0.45897710815329817,2.0,0.0],"7":[152,0],"8":[143,0],"9":[18,0],"10":[3,0],"11":[1.0763462849352421,1.0,1.0,3.0,0.26819747983619469,3.0,0.0],"12":[457.25426039536467,240.0,0.0,7116.0,821.35214200357211,374.0,0.0],"13":[4.6353101567825492,6.0,1.0,7.0,2.0118833414803348,7.0,0.0],"14":[0.77914110429447858,1.0,0.0,1.0,0.41496701638465033,2.0,0.0],"15":[0.75187457396046353,1.0,0.0,1.0,0.43207228132608194,2.0,0.0],"16":[0.67075664621676889,1.0,0.0,1.0,0.47009872415488591,2.0,0.0],"17":[0.74710293115201087,1.0,0.0,1.0,0.43482067892665488,2.0,0.0],"18":[0.76209952283571913,1.0,0.0,1.0,0.42594308610269283,2.0,0.0],"19":[0.91683708248125428,1.0,0.0,1.0,0.27622247699244651,2.0,0.0],"20":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"21":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"22":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"23":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"24":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"25":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"26":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"27":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"28":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"29":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"30":[0.00068166325835037494,0.0,0.0,1.0,0.026108681666265246,2.0,0.0],"31":[0.0,0.0,0.0,0.0,0.0,1.0,0.0],"32":[1.21813224267212,1.0,1.0,3.0,0.47888405004417572,3.0,0.0],"33":[37.702870876973925,33.744270833333331,7.2151415679908313,113.24739583333334,19.222644774423742,1463.0,0.0],"34":[23.063636413797489,22.630048380166318,5.0482454481038923,52.892425368748412,7.41230383158667,1463.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 1000: RPackage library exception: Failed to convert RObject to DataSet ---> Microsoft.Analytics.Modules.R.ErrorHandling.RException: Failed to convert RObject to DataSet ---> System.ArgumentException: An item with the same key has already been added.\r\n   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)\r\n   at Microsoft.MetaAnalytics.RDataSupport.RDataSupport.CreateDataTable(RObject robject)\r\n   at Microsoft.MetaAnalytics.RDataSupport.RDataSupport.CreateAfxObject(RObject robject)\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.MetaAnalytics.RDataSupport.RDataSupport.CreateAfxObject(RObject robject)\r\n   at Microsoft.MetaAnalytics.RDataSupport.RWorker.GetDataTable(String name)\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\r\n   --- End of inner exception stack trace ---","Warnings":[],"Duration":"00:00:11.0200331"}
    Module finished after a runtime of 00:00:11.2503721 with exit code -2
    Module failed due to negative exit code of -2" 


    • Edited by Vanja P Tuesday, November 3, 2015 7:52 PM
    Tuesday, November 3, 2015 7:35 PM

Answers

  • Hi AK,

    I was able to fix it by changing the two columns to numeric type before combining them, as in:

    p1 <- as.numeric(predictions1[, 'Scored Label Mean'])
    p2 <- as.numeric(predictions2[, 'Scored Label Mean'])
    output <- data.frame(AvgTaskMins_Pred = p1, DaysToComplete_Pred = p2)

    Thanks for your help!

    Vanja

    Tuesday, November 3, 2015 9:08 PM

All replies

  • Hey Vanja,

    What are you trying to accomplish with this code? I suspect the issue is that you're duplicating some metadata on the columns (which you can see if you str(dataset1/2)), of which we only allow unique values (such as the value for score.type).

    If you would like to paste the output of str(dataset1) and str(dataset2) we can confirm this.

    Regards,

    AK

    Tuesday, November 3, 2015 8:08 PM
  • Hi AK,

    Thanks for your reply! The script is combining the output of two "Score Model" modules. Each of them are predicting a different variable, but in both of them it's labeled "Scored Label Mean" by default.

    Here is the output of:

    print(str(predictions1[, 'Scored Label Mean']))
    print(str(predictions2[, 'Scored Label Mean']))


    [ModuleOutput]  atomic [1:1467] 4.52 11.99 8.22 7.1 9.78 ...
    [ModuleOutput]
    [ModuleOutput]  - attr(*, "feature.channel")= chr "Bayesian Linear Regression Scores"
    [ModuleOutput]
    [ModuleOutput]  - attr(*, "score.type")= chr "Assigned Label Mean"
    [ModuleOutput]
    [ModuleOutput] NULL
    [ModuleOutput]
    [ModuleOutput]  atomic [1:1467] 27.8 62.1 35.2 22 49.7 ...
    [ModuleOutput]
    [ModuleOutput]  - attr(*, "feature.channel")= chr "Bayesian Linear Regression Scores"
    [ModuleOutput]
    [ModuleOutput]  - attr(*, "score.type")= chr "Assigned Label Mean"
    [ModuleOutput]
    [ModuleOutput] NULL

    Tuesday, November 3, 2015 8:53 PM
  • Hi AK,

    I was able to fix it by changing the two columns to numeric type before combining them, as in:

    p1 <- as.numeric(predictions1[, 'Scored Label Mean'])
    p2 <- as.numeric(predictions2[, 'Scored Label Mean'])
    output <- data.frame(AvgTaskMins_Pred = p1, DaysToComplete_Pred = p2)

    Thanks for your help!

    Vanja

    Tuesday, November 3, 2015 9:08 PM
  • Excellent, glad to hear you've unblocked yourself!

    For future reference, it is likely the attribute "score.type" which must only have 1 occurrence of each value in the data.frame. In the above example, you created a df with two columns, both of which were annotated with "Assigned Label Mean".

    Regards,

    AK

    Tuesday, November 3, 2015 9:32 PM