2

When I try running the following piece of code in Spotfire Professional as a "R Script - Tibco Enterprise Runtime for R":

mydata_broken <- structure(
  list(
    Var1 = list(3.99083333270391, 3.99083333270391, 3.99083333270391, 3.99083333270391), 
    Var2 = list(3.99083333270391, 3.99083333270391, 3.99083333270391, 3.99083333270391)), 
  row.names = c("1", "2", "3", "4"), 
  class = "data.frame", 
  out.attrs = list(dim = c(2L, 2L), 
                   dimnames = list(
                     Var1 = c("Var1=3.99083333270391", "Var1=3.99083333270391"), 
                     Var2 = c("Var2=3.99083333270391", "Var2=3.99083333270391")
                     )
                   )
  )

mydata_ok <- structure(
  list(
    Var1 = list(3.99083333270391), 
    Var2 = list(3.99083333270391)), 
  row.names = "1", 
  class = "data.frame", 
  out.attrs = list(dim = c(1L, 1L), 
                   dimnames = list(
                     Var1 = "Var1=3.99083333270391", 
                     Var2 = "Var2=3.99083333270391")
                   )
  )

out <- apply(mydata_broken, 1, function(y) mean(as.numeric(y)))

I get the following error message:

TIBCO Enterprise Runtime for R returned an error: 'Error in expand.names(x) : subscript out of bounds'. at Spotfire.Dxp.Data.DataFunctions.Executors.LocalFunctionClient.OnExecuting(FunctionClient funcClient)

(rest of stack trace omitted)

However, the same code works flawlessly in plain R. If I replace mydata_broken with mydata_ok in the call to apply(), everything works as expected (both in TERR and plain R).

Things I've tried so far:

Version & configuration information

  • Spotfire 5.5.0, build version 5.5.0.31, build date: 22.05.2013
  • R version 3.0.2, 64bit (2013-09-25)
  • Windows 7, 64bit

So, my question is: Am I making some stupid mistake here? Or is this a bug in the Spotfire R runtime?

UPDATE I'd like to reopen the question, because I got a viable workaround from Spotfire support, and I'd like to add it as an answer.

Community
  • 1
  • 1
Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
  • 4
    I suspect you'll get more attention by addressing this to the commercial entity that sold you the licence - I doubt many people here have access to this. – Gavin Simpson Jun 04 '14 at 18:06
  • @GavinSimpson I guess you're right. I've contacted Spotfire Support regarding this issue. – Frank Schmitt Jun 05 '14 at 08:34
  • 1
    I'd like to reopen the question, because I got a viable workaround from Spotfire support, and I'd like to add it as an answer – Frank Schmitt Jun 13 '14 at 08:06
  • @FrankSchmitt - I get this error too in `TIBCO Spotfire 6.5.3`, but does this has to be about how `TERR` is reading the structure? As, I don't use `list()` and wondering if this still is a bug? – Chetan Arvind Patil Aug 08 '17 at 14:42
  • @ChetanArvindPatil It might be the same bug - I haven't checked in newer versions than 5.5, since I had a viable workaround (see my answer to this question). If this workaround doesn't work for you, you should contact Spotfire support. – Frank Schmitt Aug 15 '17 at 09:07

1 Answers1

2

Here's a short summary of the response I got from Spotfire support:

  • it's indeed a bug in TERR (apparently, TERR is not able to read the list() structure properly, causing a fault in the dimensions of the matrix it was supposed to create); they're currently working on fixing it
  • as a workaround, you can use c() instead of list() in the data definition

Modified definition of data that works in TERR

mydata_working <- structure(
    list(
      Var1 = c(3.99083333270391, 3.99083333270391, 3.99083333270391, 3.99083333270391), 
      Var2 = c(3.99083333270391, 3.99083333270391, 3.99083333270391, 3.99083333270391)), 
    row.names = c("1", "2", "3", "4"), 
    class = "data.frame", 
    out.attrs = list(dim = c(2L, 2L), 
                     dimnames = list(
                       Var1 = c("Var1=3.99083333270391", "Var1=3.99083333270391"), 
                       Var2 = c("Var2=3.99083333270391", "Var2=3.99083333270391")
                       )
                     )
    )
Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107