0

I'm trying to use the all_metrics() function of the iglu package in R. The function always throws an error when calling the mage_ma_single() function, which itself gets called by the mage() function. Here's the package's function's source code which leads to an error, see lines 58 to 64.

Here's the error I'm getting:

Error: Problem with mutate() column MA_Long. ℹ MA_Long = replace(MA_Long, 1:long_ma, MA_Long[long_ma]). ℹ MA_Long must be size 5 or 1, not 23.

Here's some sample data with which I can reproduce the error:

structure(list(id = c(1, 1, 1, 1, 1), time = structure(c(1611228720, 1611229080, 1611247620, 1611249960, 1611263940), class = c("POSIXct", "POSIXt"), tzone = ""), gl = c(97L, 90L, 89L, 96L, 87L)), row.names = c(NA, 5L), class = "data.frame")
Vinícius Félix
  • 8,448
  • 6
  • 16
  • 32
TIV
  • 11
  • 5
  • The problem is `long_ma` has default value as 23, we cannot change it. Since your data does not have 23 rows it returns an error. – Ronak Shah Oct 04 '21 at 13:20
  • Does that mean I need to have at least 23 observations per ID? Or could I also go into the source code of the function and set these values to 0? – TIV Oct 04 '21 at 14:03
  • I actually tried that with `iglu::all_metrics(df[sample(5, 23, replace = TRUE), ])` but it returned another error. I haven't used that package/function so I don't know how is that supposed to work. – Ronak Shah Oct 04 '21 at 14:12

1 Answers1

0

It turned out there needed to be at least 23 observations per ID in order for all_metrics() (and mage_ma_single()) to run successfully. I've mailed the package's author, Irina Gaynanova, and she'll look into providing a fix soon.

TIV
  • 11
  • 5