I am having trouble with rbindlist called via the package riskRegression
. It seems to be an issue with fill = TRUE
, but I am not sure.
There are many topics related to similar issues with rbindlist, but it has not solved my issue.
Questions: (1) Why does this specific error arise in this dataset/script, and (2) How can it be fixed?
Data sample stored in df
below.
I am quantifying the predictive performance of two independent cause-specific Cox regressions:
library(survival)
a_t7_n8_cmprsk <- coxph(Surv(event.tid, event == 1) ~ t7,
x = TRUE, data = df)
a_t0_n8_cmprsk <- coxph(Surv(event.tid, event == 1) ~ n8,
x = TRUE, data = df)
The predictive performance is quantified using
library(riskRegression)
u_n8_cmprsk <- Score(list("t7_n8" = a_t7_n8_cmprsk, "t0_n8" = a_t0_n8_cmprsk),
Hist(event.tid, event == 1) ~ 1,
data = df,
times = c(12, 30, 60),
plots=c("cal"),
B = 100,
seed = 1,
split.method = "loob",
metrics = c("auc","brier"))
But - I receive the following error:
Error in rbindlist(foreach::foreach(b = 1:B, .export = exports, .packages = "data.table", : Item 79 has 2 columns, inconsistent with item 1 which has 9 columns. To fill missing columns use fill=TRUE.
Why and how to fix it?
df <- structure(list(t7 = c("pT1", "pT4a", "pT1", "pT4a", "pT1", "pT2",
"pT2", "pT2", "pT3", "pT1", "pT2", "pT2", "pT1", "pT3", "pT3",
"pT2", "pT2", "pT1", "pT1", "pT1", "pT4a", "pT1", "pT4a", "pT3",
"pT1", "pT2", "pT2", "pT4a", "pT4a", "pT1", "pT4a", "pT2", "pT4a",
"pT3", "pT1", "pT2", "pT4a", "pT1", "pT2", "pT1", "pT1", "pT2",
"pT1", "pT2", "pT1", "pT2", "pT3", "pT4a", "pT2", "pT4a"), n8 = c("pN2b",
"pN0", "pN0", "pN0", "pN0", "pN0", "pN0", "pN0", "pN3b", "pN0",
"pN0", "pN1", "pN1", "pN3b", "pN0", "pN0", "pN1", "pN0", "pN0",
"pN2b", "pN0", "pN3b", "pN3b", "pN3b", "pN0", "pN0", "pN2b",
"pN3b", "pN1", "pN0", "pN0", "pN0", "pN3b", "pN3b", "pN2b", "pN0",
"pN0", "pN0", "pN3b", "pN1", "pN0", "pN1", "pN3b", "pN0", "pN3b",
"pN0", "pN3b", "pN0", "pN0", "pN1"), event.tid = c(82.4, 23.9,
20.9, 0.4, 6.7, 124.2, 42.4, 38.8, 5.1, 6.5, 40.5, 15.3, 60.3,
32.5, 62.9, 16.8, 14.8, 141, 63.4, 97.3, 13.2, 5.4, 134, 19.1,
59.8, 179.5, 2.6, 130.7, 18.5, 40.5, 13.7, 52.9, 2.4, 9.3, 94.5,
33.5, 79.3, 37.7, 12.7, 5.9, 98.5, 0.7, 17.5, 81.7, 24.4, 33.5,
3.1, 3.1, 84.3, 7.9), event = c(0, 1, 0, 2, 1, 0, 0, 1, 1, 0,
0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 1, 0, 1, 0, 0,
2, 1, 1, 0, 2, 1, 2, 0, 1, 0, 2, 0, 0, 1, 0, 1, 2, 0, 1)), row.names = c(NA,
-50L), class = "data.frame", na.action = structure(262:446, names = c("262",
"263", "264", "265", "266", "267", "268", "269", "270", "271",
"272", "273", "274", "275", "276", "277", "278", "279", "280",
"281", "282", "283", "284", "285", "286", "287", "288", "289",
"290", "291", "292", "293", "294", "295", "296", "297", "298",
"299", "300", "301", "302", "303", "304", "305", "306", "307",
"308", "309", "310", "311", "312", "313", "314", "315", "316",
"317", "318", "319", "320", "321", "322", "323", "324", "325",
"326", "327", "328", "329", "330", "331", "332", "333", "334",
"335", "336", "337", "338", "339", "340", "341", "342", "343",
"344", "345", "346", "347", "348", "349", "350", "351", "352",
"353", "354", "355", "356", "357", "358", "359", "360", "361",
"362", "363", "364", "365", "366", "367", "368", "369", "370",
"371", "372", "373", "374", "375", "376", "377", "378", "379",
"380", "381", "382", "383", "384", "385", "386", "387", "388",
"389", "390", "391", "392", "393", "394", "395", "396", "397",
"398", "399", "400", "401", "402", "403", "404", "405", "406",
"407", "408", "409", "410", "411", "412", "413", "414", "415",
"416", "417", "418", "419", "420", "421", "422", "423", "424",
"425", "426", "427", "428", "429", "430", "431", "432", "433",
"434", "435", "436", "437", "438", "439", "440", "441", "442",
"443", "444", "445", "446"), class = "omit"))