none
Rounding bug inside rxVarInfo attributes when RxSpssData() is used. RRS feed

  • Question

  • I have discovered what I think is a bug in the way MicrosoftR handles metadata from .sav files from SPSS.

    Here is a summary of the Variable View:

    ColumnA: 1 - Yes, 2 - No
    ColumnB: 0.33 - Yes, 0.5 - Maybe, 0.66 - No, 0.99 - Why not, 1.00 - Yes, for sure.
    ColumnC: A - Yes, B - No

    My code:

    library(RevoScaleR)
    
    df <- RxSpssData(
      "RoundingTest.sav", 
      stringsAsFactors = FALSE, 
      labelsAsInfo = TRUE, 
      labelsAsLevels = TRUE,
      mapMissingCodes = "none" 
    )
    
    test = rxImport(df)

    The data reads in fine:

     ColumnA ColumnB ColumnC Var0001
    1     Yes    0.33     Yes      NA
    2      No    0.50     Yes      NA
    3     Yes    0.66      No      NA

    The valueInfoCodes, however, do not:

    attr(test$ColumnA, ".rxValueInfoCodes") # NULL
    attr(test$ColumnB, ".rxValueInfoCodes") # "0" "0" "0" "0" "1"
    attr(test$ColumnC, ".rxValueInfoCodes") # NULL

    It seems to be using some sort of floor function on the metadata in the numeric columns before converting them to character strings.

    I have tried using options(scipen = 12) and rxOptions(numDigits = 12) with no success. Using rxDataStep instead of rxImport doesn't work. I believe the error to be somewhere in the RxSpssData() function.

    • Has anyone experienced this with RxSpssData, or any other file type?
    • Is there a workaround?
    • Is there a formal way to report it to Microsoft if it's a genuine bug?

    Thanks!

    Also, my session info:

    R version 3.3.2 (2016-10-31)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows >= 8 x64 (build 9200)

    Monday, April 24, 2017 7:48 AM