In ref.study != ref.data : longer object length is not a multiple of shorter object length

Hey, so I’m trying to conduct a meta-analysis of Kaplan-Meier curves and I’m using the "metasurvival" package. Even though every column is of the same length, R keeps telling me that "In ref.study != ref.data : longer object length is not a multiple of shorter object length". Does anyone know how to solve this? Thank you in advance!

library(metaSurvival)

dat<-Example

attach(dat)
head(dat)

results<-msurv(study = study, time = time, n.risk = NbRisk, surv.rate = survival, confidence = "Greenwood", correctionFlag = TRUE, correctionVal = c(0.25,0.5))

Created on 2023-03-19 with reprex v2.0.2
Example data set:

study time survival NbRisk censor event
1 0.0000000 1.0000000 20 0 0
1 0.4154789 0.9982487 20 0 0
1 0.4212492 0.9877357 20 0 0
1 0.4212492 0.9669454 20 0 1
1 0.4280217 0.9506460 19 0 0
1 0.4295839 0.9506460 19 0 0
1 0.5407174 0.9506460 19 0 0
1 0.5970652 0.9506460 19 0 0
1 0.6534130 0.9506460 19 0 0
1 0.7661087 0.9506460 19 0 0
1 2.2042515 0.9506460 19 0 0
1 2.3311967 0.9499877 19 0 0
1 2.3600478 0.9285440 19 0 0
1 2.3600478 0.9181488 19 0 1
1 2.3645358 0.9181488 18 0 0
1 2.5043037 0.9015010 18 0 0
1 2.6312488 0.9015010 18 0 0
1 2.7581940 0.9015010 18 0 0
1 2.8851391 0.9009637 18 0 0
1 2.9543819 0.8786882 18 0 0
1 2.9543819 0.8682930 18 0 1
1 2.9607292 0.8537795 17 0 0
1 2.9630373 0.8537795 17 0 0
1 3.0928676 0.8514909 17 0 0
1 3.4737030 0.8514692 17 0 0
1 4.1084288 0.8512038 17 0 0
1 4.1949823 0.8252851 17 0 0
1 4.1949823 0.8148900 17 0 1
1 4.1963139 0.8148900 16 0 0
1 4.2101291 0.8029010 16 0 0
1 4.3392381 0.8014745 16 0 0
1 4.4661833 0.8014386 16 0 0
1 4.5931284 0.8014386 16 0 0
1 4.7200736 0.8014386 16 0 0
1 4.8470187 0.8014386 16 0 0
1 4.9739639 0.8000064 16 0 0
1 4.9843503 0.7883528 16 0 0
1 4.9855043 0.7777897 16 0 0
1 4.9855043 0.7673945 16 0 1
1 4.9927931 0.7536950 15 0 0
1 5.1239900 0.7507022 15 0 0
1 5.1586114 0.7256135 15 0 0
1 5.1586114 0.7152184 15 0 1
1 5.1619086 0.7152184 14 0 0
1 5.1681153 0.7030628 14 0 0
1 5.2855565 0.7001052 14 0 0
1 5.2866057 0.6870087 14 0 0
1 5.2913268 0.6753252 14 0 0
1 5.2913268 0.6649300 14 0 1
1 5.3064736 0.6529410 13 0 0
1 5.4355826 0.6512783 13 0 0
1 5.5625278 0.6502545 13 0 0
1 5.5751174 0.6370250 13 0 0
1 5.5798385 0.6253736 13 0 0
1 5.5798385 0.6149785 13 0 1
1 5.5949853 0.6030780 12 0 0
1 5.7240943 0.6012086 12 0 0
1 5.8510395 0.5997123 12 0 0
1 5.8625799 0.5890982 12 0 0
1 5.8625799 0.5724817 12 0 1
1 5.8716908 0.5524062 11 0 0
1 5.8914311 0.5255739 11 0 0
1 5.8914311 0.5151787 11 0 1
1 5.8946368 0.5151787 10 0 0
1 5.9004070 0.5022378 10 0 0
1 6.0241465 0.4992784 10 0 0
1 6.0299167 0.4888442 10 0 0
1 6.0299167 0.4160781 10 0 2
1 6.0332574 0.4022326 8 0 0
1 6.1626321 0.4017921 8 0 0
1 7.0454779 0.3999985 8 0 0
1 7.0570184 0.3893205 8 0 0
1 7.0570184 0.3685302 8 0 1
1 7.0670404 0.3538457 7 0 0
1 7.2012742 0.3517642 7 0 0
1 7.3282194 0.3517642 7 0 0
1 7.8879321 0.3291221 7 0 0
1 7.8879321 0.3187269 7 0 1
1 7.8948564 0.3187269 6 0 0
1 7.9052428 0.3187269 6 0 0
1 7.9990091 0.3012503 6 0 0
1 9.1285324 0.3012503 6 0 0
1 9.2554776 0.3008048 6 0 0
1 9.2958692 0.2791146 6 0 0
1 9.2958692 0.2687195 6 0 1
1 9.3027935 0.2687195 5 0 0
1 9.3042040 0.2540460 5 0 0
1 9.4069462 0.2505342 5 0 0
1 9.5209084 0.2505342 5 0 0
1 9.6478535 0.2505342 5 0 0
1 9.7747987 0.2505342 5 0 0
1 9.9017438 0.2505342 5 0 0
1 11.0442502 0.2500453 5 0 0
1 11.0796959 0.2343392 5 0 0
1 11.0915661 0.2199622 5 0 1
1 11.0946638 0.2034699 4 0 0
1 11.2288977 0.2008290 4 0 0
1 11.3558428 0.2007931 4 0 0
1 11.4862826 0.2007931 4 0 0
1 11.6097331 0.2007931 4 0 0
1 11.7366783 0.2000411 4 0 0
1 11.7650856 0.1868224 4 0 0
1 11.7655294 0.1735286 4 0 1
1 11.7655294 0.1423431 3 0 0
1 11.7795429 0.1331469 3 0 0
1 11.9097853 0.1331469 3 0 0
1 12.0367304 0.1331469 3 0 0
2 0.000000 1.0000000 16 4 0
2 2.972599 0.9898192 12 0 0
2 2.972868 0.9528280 12 0 1
2 3.007984 0.9360596 11 3 0
2 5.002664 0.9356764 8 1 0
2 5.978137 0.9349110 7 0 0
2 5.978271 0.9164154 7 0 0
2 5.978406 0.8979198 7 0 0
2 5.978540 0.8794242 7 0 0
2 5.978675 0.8609287 7 0 0
2 5.978776 0.8470570 7 0 1
2 5.978843 0.8378092 6 0 0
2 5.978910 0.8285614 6 0 0
2 5.978977 0.8193136 6 0 0
2 5.979044 0.8100658 6 0 0
2 5.979112 0.8008180 6 0 0
2 5.979179 0.7915702 6 0 0
2 5.979246 0.7823224 6 0 0
2 5.979313 0.7730746 6 0 0
2 5.979381 0.7638268 6 0 0
2 5.979414 0.7592029 6 0 0
2 5.979448 0.7545790 6 0 0
2 5.979481 0.7499551 6 0 0
2 5.979515 0.7453312 6 0 0
2 5.979549 0.7407073 6 0 0
2 5.979582 0.7360834 6 0 0
2 5.979616 0.7314595 6 0 0
2 5.979650 0.7268356 6 0 0
2 5.979683 0.7222117 6 0 0
2 5.979717 0.7175878 6 0 1
2 5.979750 0.7129639 5 0 0
2 5.979784 0.7083400 5 0 0
2 5.979818 0.7037161 5 0 0
2 5.979851 0.6990922 5 0 0
2 5.979885 0.6944683 5 0 0
2 5.979986 0.6805966 5 0 0
2 5.980053 0.6713488 5 0 0
2 5.980087 0.6667249 5 0 0
2 5.980120 0.6621010 5 0 0
2 5.980154 0.6574771 5 0 0
2 5.980187 0.6528532 5 0 0
2 5.980221 0.6482293 5 0 0
2 5.980255 0.6436054 5 0 0
2 5.980288 0.6389815 5 0 0
2 5.980322 0.6343576 5 0 0
2 5.980355 0.6297337 5 0 0
2 5.980389 0.6251098 5 0 0
2 5.980423 0.6204859 5 0 0
2 5.980456 0.6158620 5 0 0
2 5.980490 0.6112381 5 0 0
2 5.980524 0.6066142 5 0 0
2 5.980557 0.6019903 5 0 0
2 5.980591 0.5973664 5 0 0
2 5.980624 0.5927425 5 0 0
2 5.980658 0.5881186 5 0 1
2 5.980692 0.5834948 4 0 0
2 5.980725 0.5788709 4 0 0
2 5.980759 0.5742470 4 0 0
2 5.983340 0.5630996 4 4 0
2 8.986028 0.5563300 0 0 0
2 8.986095 0.5470822 0 0 0
2 8.986163 0.5378344 0 0 0
2 8.986230 0.5285866 0 0 0
2 8.986297 0.5193388 0 0 0
2 8.986364 0.5100910 0 0 0
2 8.986431 0.5008432 0 0 0
2 8.986499 0.4915954 0 0 0
2 8.986532 0.4869715 0 0 0
2 8.986566 0.4823476 0 0 0
2 8.986633 0.4730998 0 0 0
2 8.986700 0.4638520 0 0 0
2 8.986768 0.4546042 0 0 0
2 8.986835 0.4453564 0 0 0
2 8.986936 0.4314847 0 0 0
2 8.987003 0.4222369 0 0 0
2 8.987070 0.4129891 0 0 0
2 8.987137 0.4037413 0 0 0
2 8.987205 0.3944935 0 0 0
2 8.987272 0.3852457 0 0 0
2 8.987339 0.3759979 0 0 0
2 8.987406 0.3667501 0 0 0
2 8.987474 0.3575023 0 0 0
2 8.987743 0.3205112 0 0 0
2 10.982461 0.3149261 0 0 0
2 11.992995 0.3049061 0 0 0
2 11.993264 0.2679149 0 0 0
2 11.993398 0.2494194 0 0 0
2 11.993466 0.2401716 0 0 0
2 11.993533 0.2309238 0 0 0
2 11.993600 0.2216760 0 0 0
2 11.993667 0.2124282 0 0 0
2 11.993734 0.2031804 0 0 0
2 12.000000 0.1924876 0 0 0
3 0.0000000 1.0000000 86 0 0
3 0.3771191 0.9664148 86 1 3
3 0.9584646 0.9645975 82 1 0
3 1.5202772 0.9636304 81 1 0
3 2.0530596 0.9553136 80 1 1
3 2.3586153 0.9493715 78 0 0
3 2.5568189 0.9394176 78 1 1
3 2.7635765 0.9273941 76 0 1
3 2.9470398 0.9136588 75 1 1
3 3.2603652 0.8971583 73 0 2
3 3.4837739 0.8797844 71 0 1
3 3.5739556 0.8688014 70 1 1
3 3.7992385 0.8468332 68 0 1
3 3.8091664 0.8468332 67 0 0
3 3.8893630 0.8376799 67 0 1
3 4.0693268 0.8285221 66 1 1
3 4.1639719 0.8197711 64 0 1
3 4.3396434 0.8028921 63 0 1
3 4.3848484 0.7937411 62 0 1
3 4.6543659 0.7937274 61 1 0
3 4.7446046 0.7809147 60 0 1
3 5.0143505 0.7735821 59 0 0
3 5.1493946 0.7644266 59 0 1
3 5.1497942 0.7516184 58 0 1
3 5.1501366 0.7406400 57 1 1
3 5.2373718 0.7127646 55 0 2
3 5.2414027 0.6948920 53 0 1
3 5.4398484 0.6821550 52 1 1
3 6.0777028 0.6270670 50 1 4
3 6.3220985 0.6106694 45 0 1
3 6.5929288 0.5685717 44 0 3
3 6.5934425 0.5521041 41 0 1
3 6.6387045 0.5411234 40 1 1
3 6.9234504 0.5285246 38 1 1
3 7.4060170 0.5137801 36 1 1
3 7.9950469 0.5061289 34 1 1
3 8.5290893 0.4949369 32 1 0
3 9.0210135 0.4832529 31 0 1
3 9.3359918 0.4732862 30 1 1
3 9.6417921 0.4699296 28 1 0
3 10.1383012 0.4593659 27 1 0
3 10.5073361 0.4476621 26 0 1
3 10.6486332 0.4203638 25 0 2
3 10.8203930 0.4073404 23 0 0
3 10.8658263 0.3908704 23 0 1
3 10.8662829 0.3762326 22 1 1
3 11.0413336 0.3628733 20 1 1
3 11.4545212 0.3614794 18 0 0
3 11.7653026 0.3560598 18 0 0
3 11.9351305 0.3426886 18 0 1
3 12.3501705 0.3267543 17 1 1

column lengths are not the objects that the function is comparing

library(metaSurvival)

d <- data.frame(
       Study = c(1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
                 1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
                 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
                 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
                 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
                 3,3,3,3),
        Time = c(0,0.4154789,0.4212492,0.4212492,
                 0.4280217,0.4295839,0.5407174,0.5970652,0.653413,0.7661087,
                 2.2042515,2.3311967,2.3600478,2.3600478,2.3645358,2.5043037,
                 2.6312488,2.758194,2.8851391,2.9543819,2.9543819,2.9607292,
                 2.9630373,3.0928676,3.473703,4.1084288,4.1949823,4.1949823,
                 4.1963139,4.2101291,4.3392381,4.4661833,4.5931284,
                 4.7200736,4.8470187,4.9739639,4.9843503,4.9855043,4.9855043,
                 4.9927931,5.12399,5.1586114,5.1586114,5.1619086,5.1681153,
                 5.2855565,5.2866057,5.2913268,5.2913268,5.3064736,5.4355826,
                 5.5625278,5.5751174,5.5798385,5.5798385,5.5949853,
                 5.7240943,5.8510395,5.8625799,5.8625799,5.8716908,5.8914311,
                 5.8914311,5.8946368,5.900407,6.0241465,6.0299167,6.0299167,
                 6.0332574,6.1626321,7.0454779,7.0570184,7.0570184,7.0670404,
                 7.2012742,7.3282194,7.8879321,7.8879321,7.8948564,
                 7.9052428,7.9990091,9.1285324,9.2554776,9.2958692,9.2958692,
                 9.3027935,9.304204,9.4069462,9.5209084,9.6478535,9.7747987,
                 9.9017438,11.0442502,11.0796959,11.0915661,11.0946638,
                 11.2288977,11.3558428,11.4862826,11.6097331,11.7366783,
                 11.7650856,11.7655294,11.7655294,11.7795429,11.9097853,12.0367304,
                 0,2.972599,2.972868,3.007984,5.002664,5.978137,5.978271,
                 5.978406,5.97854,5.978675,5.978776,5.978843,5.97891,
                 5.978977,5.979044,5.979112,5.979179,5.979246,5.979313,5.979381,
                 5.979414,5.979448,5.979481,5.979515,5.979549,5.979582,
                 5.979616,5.97965,5.979683,5.979717,5.97975,5.979784,
                 5.979818,5.979851,5.979885,5.979986,5.980053,5.980087,5.98012,
                 5.980154,5.980187,5.980221,5.980255,5.980288,5.980322,
                 5.980355,5.980389,5.980423,5.980456,5.98049,5.980524,
                 5.980557,5.980591,5.980624,5.980658,5.980692,5.980725,5.980759,
                 5.98334,8.986028,8.986095,8.986163,8.98623,8.986297,
                 8.986364,8.986431,8.986499,8.986532,8.986566,8.986633,8.9867,
                 8.986768,8.986835,8.986936,8.987003,8.98707,8.987137,
                 8.987205,8.987272,8.987339,8.987406,8.987474,8.987743,
                 10.982461,11.992995,11.993264,11.993398,11.993466,11.993533,
                 11.9936,11.993667,11.993734,12,0,0.3771191,0.9584646,
                 1.5202772,2.0530596,2.3586153,2.5568189,2.7635765,2.9470398,
                 3.2603652,3.4837739,3.5739556,3.7992385,3.8091664,3.889363,
                 4.0693268,4.1639719,4.3396434,4.3848484,4.6543659,4.7446046,
                 5.0143505,5.1493946,5.1497942,5.1501366,5.2373718,
                 5.2414027,5.4398484,6.0777028,6.3220985,6.5929288,6.5934425,
                 6.6387045,6.9234504,7.406017,7.9950469,8.5290893,9.0210135,
                 9.3359918,9.6417921,10.1383012,10.5073361,10.6486332,
                 10.820393,10.8658263,10.8662829,11.0413336,11.4545212,11.7653026,
                 11.9351305,12.3501705),
    Survival = c(1,0.9982487,0.9877357,0.9669454,
                 0.950646,0.950646,0.950646,0.950646,0.950646,0.950646,0.950646,
                 0.9499877,0.928544,0.9181488,0.9181488,0.901501,0.901501,
                 0.901501,0.9009637,0.8786882,0.868293,0.8537795,0.8537795,
                 0.8514909,0.8514692,0.8512038,0.8252851,0.81489,0.81489,
                 0.802901,0.8014745,0.8014386,0.8014386,0.8014386,0.8014386,
                 0.8000064,0.7883528,0.7777897,0.7673945,0.753695,
                 0.7507022,0.7256135,0.7152184,0.7152184,0.7030628,0.7001052,
                 0.6870087,0.6753252,0.66493,0.652941,0.6512783,0.6502545,
                 0.637025,0.6253736,0.6149785,0.603078,0.6012086,0.5997123,
                 0.5890982,0.5724817,0.5524062,0.5255739,0.5151787,0.5151787,
                 0.5022378,0.4992784,0.4888442,0.4160781,0.4022326,
                 0.4017921,0.3999985,0.3893205,0.3685302,0.3538457,0.3517642,
                 0.3517642,0.3291221,0.3187269,0.3187269,0.3187269,0.3012503,
                 0.3012503,0.3008048,0.2791146,0.2687195,0.2687195,0.254046,
                 0.2505342,0.2505342,0.2505342,0.2505342,0.2505342,
                 0.2500453,0.2343392,0.2199622,0.2034699,0.200829,0.2007931,
                 0.2007931,0.2007931,0.2000411,0.1868224,0.1735286,0.1423431,
                 0.1331469,0.1331469,0.1331469,1,0.9898192,0.952828,0.9360596,
                 0.9356764,0.934911,0.9164154,0.8979198,0.8794242,
                 0.8609287,0.847057,0.8378092,0.8285614,0.8193136,0.8100658,
                 0.800818,0.7915702,0.7823224,0.7730746,0.7638268,0.7592029,
                 0.754579,0.7499551,0.7453312,0.7407073,0.7360834,0.7314595,
                 0.7268356,0.7222117,0.7175878,0.7129639,0.70834,0.7037161,
                 0.6990922,0.6944683,0.6805966,0.6713488,0.6667249,0.662101,
                 0.6574771,0.6528532,0.6482293,0.6436054,0.6389815,
                 0.6343576,0.6297337,0.6251098,0.6204859,0.615862,0.6112381,
                 0.6066142,0.6019903,0.5973664,0.5927425,0.5881186,0.5834948,
                 0.5788709,0.574247,0.5630996,0.55633,0.5470822,0.5378344,
                 0.5285866,0.5193388,0.510091,0.5008432,0.4915954,0.4869715,
                 0.4823476,0.4730998,0.463852,0.4546042,0.4453564,
                 0.4314847,0.4222369,0.4129891,0.4037413,0.3944935,0.3852457,
                 0.3759979,0.3667501,0.3575023,0.3205112,0.3149261,0.3049061,
                 0.2679149,0.2494194,0.2401716,0.2309238,0.221676,0.2124282,
                 0.2031804,0.1924876,1,0.9664148,0.9645975,0.9636304,
                 0.9553136,0.9493715,0.9394176,0.9273941,0.9136588,0.8971583,
                 0.8797844,0.8688014,0.8468332,0.8468332,0.8376799,0.8285221,
                 0.8197711,0.8028921,0.7937411,0.7937274,0.7809147,
                 0.7735821,0.7644266,0.7516184,0.74064,0.7127646,0.694892,
                 0.682155,0.627067,0.6106694,0.5685717,0.5521041,0.5411234,
                 0.5285246,0.5137801,0.5061289,0.4949369,0.4832529,0.4732862,
                 0.4699296,0.4593659,0.4476621,0.4203638,0.4073404,0.3908704,
                 0.3762326,0.3628733,0.3614794,0.3560598,0.3426886,
                 0.3267543),
      NbRisk = c(20,20,20,20,19,19,19,19,19,
                 19,19,19,19,19,18,18,18,18,18,18,18,
                 17,17,17,17,17,17,17,16,16,16,16,16,16,
                 16,16,16,16,16,15,15,15,15,14,14,14,
                 14,14,14,13,13,13,13,13,13,12,12,12,12,
                 12,11,11,11,10,10,10,10,10,8,8,8,8,8,
                 7,7,7,7,7,6,6,6,6,6,6,6,5,5,5,
                 5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,3,
                 3,3,3,16,12,12,11,8,7,7,7,7,7,7,6,
                 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
                 6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,
                 5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,86,86,82,81,80,78,78,76,75,73,71,
                 70,68,67,67,66,64,63,62,61,60,59,59,
                 58,57,55,53,52,50,45,44,41,40,38,36,34,
                 32,31,30,28,27,26,25,23,23,22,20,18,
                 18,18,17),
      censor = c(0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,4,0,0,3,1,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,1,1,1,1,0,1,0,1,0,0,1,0,0,0,1,
                 0,0,0,1,0,0,0,0,1,0,0,1,1,0,0,
                 0,1,1,1,1,1,0,1,1,1,0,0,0,0,1,1,
                 0,0,0,1),
       event = c(0,0,0,1,0,0,0,0,0,0,0,
                 0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,
                 1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,
                 1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,
                 0,1,0,0,1,0,0,0,0,2,0,0,0,0,1,0,
                 0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,
                 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,
                 0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
                 0,3,0,0,1,0,1,1,1,2,1,1,1,0,1,1,
                 1,1,1,0,1,0,1,1,1,2,1,1,4,1,3,
                 1,1,1,1,1,0,1,1,0,0,1,2,0,1,1,1,
                 0,0,1,1)
)

# conformed column names to those used in metasurvival::exampleData
# as used in the help(msurv) example and
# following help(msurv) example attach the data frame;
# this is something that should be avoided, the function
# should have been written to take a data = argument so
# that it wouldn't be necessary
# to avoid future problems, either specify all arguments
# as your_data$study ... etc OR
# be sure to begin each use in a fresh R session

attach(d)
results <- msurv(study = Study, time = Time, n.risk = NbRisk, surv.rate = Survival, confidence = "Greenwood", correctionFlag = TRUE, correctionVal = c(0.25,0.5))
#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length

#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length

#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length
results
#> $verif.data
#>   Sstudy check
#> 1      1     0
#> 2      2     0
#> 3      3     0
#> 
#> $summary.fixed
#> [1] NA
#> 
#> $median.fixed
#> [1] NA
#> 
#> $mean.fixed
#> [1] NA
#> 
#> $heterogeneity
#> [1] NA
#> 
#> $summary.random
#> [1] NA
#> 
#> $median.random
#> [1] NA
#> 
#> $mean.random
#> [1] NA

# within msurv, modified to conform to names of corresponding
# attached data frame d
verif <- function(x) {
  IndiceTimes <- sort(unique(Time))
  ref.study <- sort(Time[Study == x])
  ref.data <- IndiceTimes[IndiceTimes <= max(ref.study)]
  return(1 * (sum(ref.study != ref.data) == 0))
}

# 1:3 corresponds to the three studies
sapply(1:3,verif)
#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length

#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length

#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length
#> [1] 0 0 0

# each has the identical issue
verif(1)
#> Warning in ref.study != ref.data: longer object length is not a multiple of
#> shorter object length
#> [1] 0

# bring objects within verif into .Global

(IndiceTimes <- sort(unique(Time))) |> length()
#> [1] 234
(ref.study <- sort(Time[Study == 1]) ) |> length()
#> [1] 107
(ref.data <- IndiceTimes[IndiceTimes <= max(ref.study)]) |> length()
#> [1] 233

Created on 2023-03-21 with reprex v2.0.2

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.