0

我有下面的交叉表

              MARITAL_STATUS
bal_bands      COHABIT DIVORCED MARRIED OTHER SEPARATED SINGLE WIDOW
  <£0               30       65     383    58        13    935   176
  £0                20      128     271    41        12    485   214
  £1-100            11       20      91    22         0    567   112
  £100.01-150        5       17      21    13         0    352   147
  £150.01-200        0        9      45    12         4    332    28
  £200.01-£300       7       16      70     9         7    548   114
  £300.01-400       17        6      51     5         9    472    19
  £400.01-500        6        9      33     2         2    511    39
  £500.01-750        5       12      33     8         0    363    83
  £750.01-1000       8        0      44     8         0    187     8
  £1000.01+         14       24      61    19         3    476    30

我想用 auto_crosstab_to_wb 把它读出来,但我一直收到错误

m[2, ] 中的错误:下标越界

我正在使用的代码是:

titles = c("Ending Balance vs Marital Status", "Inital Analysis")
wb <- auto_crosstab_to_wb(test2, titles = titles, footers = footers)
openxlsx::openXL(wb)

可重现的例子:

    structure(c(30L, 20L, 11L, 5L, 0L, 7L, 17L, 6L, 5L, 8L, 14L, 
65L, 128L, 20L, 17L, 9L, 16L, 6L, 9L, 12L, 0L, 24L, 383L, 271L, 
91L, 21L, 45L, 70L, 51L, 33L, 33L, 44L, 61L, 58L, 41L, 22L, 13L, 
12L, 9L, 5L, 2L, 8L, 8L, 19L, 13L, 12L, 0L, 0L, 4L, 7L, 9L, 2L, 
0L, 0L, 3L, 935L, 485L, 567L, 352L, 332L, 548L, 472L, 511L, 363L, 
187L, 476L, 176L, 214L, 112L, 147L, 28L, 114L, 19L, 39L, 83L, 
8L, 30L), .Dim = c(11L, 7L), .Dimnames = structure(list(bal_bands = c("<£0", 
"£0", "£1-100", "£100.01-150", "£150.01-200", "£200.01-£300", 
"£300.01-400", "£400.01-500", "£500.01-750", "£750.01-1000", 
"£1000.01+"), MARITAL_STATUS = c("COHABIT", "DIVORCED", "MARRIED", 
"OTHER", "SEPARATED", "SINGLE", "WIDOW")), .Names = c("bal_bands", 
"MARITAL_STATUS")), class = c("xtabs", "table"), call = xtabs(formula = ~bal_bands + 
    MARITAL_STATUS, data = all_data, exclude = c("", NULL, NA)))
4

0 回答 0