title: Why is survival::tmerge suddenly giving error "neither a tstop argument nor an initial event argument was found"?
body: <p>I'm trying to run the following code, including <em>survival::tmerge()</em> to conduct survival analysis with time-varying covariates, but i always get the error</p>
  <blockquote>
  <p>Error in tmerge(df.merge %&gt;% select(CODE98, id), df.long, id = CODE98,  :
  neither a tstop argument nor an initial event argument was found&gt;</p>
  </blockquote>
  <p>I wrote this code some months ago and it worked properly. I noticed that it started giving error after updating R to version 4.0.2</p>
  <pre><code>df &lt;- 
  structure(list(CODE98 = structure(c(4, 8, 9, 10, 13, 17, 18, 
                                      19, 20, 23, 26, 28, 30, 32, 33, 35, 37, 38, 41, 42, 45, 46, 47, 
                                      49, 50, 51, 53, 54, 56, 59, 61, 62, 65, 68, 69, 70, 72, 73, 77, 
                                      78, 80, 82, 84, 86, 87, 88, 89, 90, 91, 93), label = &quot;Subject ID code/Codice di soggetto&quot;), 
                 X_DATEL = structure(c(10653, 10744, 10533, 10735, 10611, 
                                       10556, 10744, 10764, 10673, 10751, 10541, 10576, 10610, 10625, 
                                       10709, 10667, 10534, 10540, 10646, 10715, 10632, 10757, 10611, 
                                       10589, 10618, 10569, 10638, 10701, 10681, 10743, 10709, 10632, 
                                       10666, 10701, 10555, 10673, 10701, 10681, 10680, 10701, 10604, 
                                       10520, 10520, 10764, 10694, 10736, 10749, 10666, 10730, 10695
                 ), label = &quot;Date of Baseline fasting blood/urine&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 Y_DATEL = structure(c(11797, NA, 11748, 11792, NA, 11734, 
                                       11773, NA, 11779, 11811, 11734, 11748, NA, 11769, 11790, 
                                       11811, 11699, NA, 11734, 11839, NA, 11783, 11741, 11741, 
                                       NA, NA, 11786, 11783, NA, 11811, 11804, 11837, NA, 11839, 
                                       NA, 11839, NA, 11850, 11734, NA, 11837, 11699, NA, 11781, 
                                       NA, 11809, 11783, 11804, 11825, NA), label = &quot;Date of Followup 1 fasting blood/urine&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 Z_DATEL = structure(c(12934, 12957, 12901, NA, NA, 12832, 
                                       NA, 12964, 12920, NA, 12831, 12831, 12874, 12861, 12944, 
                                       NA, 12896, NA, 12824, 12969, NA, 12957, 12891, 12852, NA, 
                                       NA, 12878, 12962, NA, 12885, NA, 12884, NA, 13277, NA, NA, 
                                       NA, 12922, 12852, NA, 12857, 12772, NA, NA, 12922, 12950, 
                                       13284, 12874, 12934, NA), label = &quot;Date of Followup 2 fasting blood/urine&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 Q_DATEL = structure(c(13934, NA, 13977, NA, NA, 13976, NA, 
                                       14039, 13976, NA, 13948, 13934, 13969, 14057, 13969, NA, 
                                       13906, NA, 13941, 14046, 13969, 13993, NA, 13941, NA, NA, 
                                       13973, 13978, NA, NA, NA, 13990, NA, 13945, 13993, NA, NA, 
                                       NA, 14026, NA, 13913, 13913, NA, NA, NA, 13927, 13864, 13920, 
                                       13955, 14028), label = &quot;Date of Followup 3 fasting blood/urine&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 C_DATEL = structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                       NA, 15888, NA, NA, NA, 15860, NA, NA, NA, 15922, NA, NA, 
                                       NA, NA, 16003, NA, NA, NA, NA, NA, NA, NA, 15873, NA, NA, 
                                       16016, NA, NA, NA, 15965, NA, NA, 15980, NA, NA, NA, NA, 
                                       15952, NA, 15869, 15868), label = &quot;Date of Followup 4 fasting blood/urine&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 X_AGEL = structure(c(79, 80, 78, 83, 90, 81, 78, 84, 74, 
                                      87, 75, 68, 71, 66, 73, 75, 67, 83, 66, 67, 75, 69, 83, 65, 
                                      67, 74, 85, 71, 73, 83, 85, 75, 88, 74, 85, 66, 82, 88, 69, 
                                      84, 66, 69, 86, 86, 74, 83, 72, 78, 66, 80), label = &quot;Age at Baseline fasting blood/urine(yrs)&quot;), 
                 Y_AGEL = structure(c(82, NA, 81, 86, NA, 84, 81, NA, 77, 
                                      90, 78, 72, NA, 69, 76, 78, 70, NA, 69, 70, NA, 72, 86, 69, 
                                      NA, NA, 88, 74, NA, 86, 88, 78, NA, 77, NA, 69, NA, 91, 71, 
                                      NA, 70, 72, NA, 89, NA, 86, 75, 81, 69, NA), label = &quot;Age at Followup 1 fasting blood/urine(yr&quot;), 
                 Z_AGEL = structure(c(85, 86, 84, NA, NA, 87, NA, 90, 80, 
                                      NA, 81, 74, 77, 72, 79, NA, 73, NA, 72, 73, NA, 75, 89, 72, 
                                      NA, NA, 91, 77, NA, 89, NA, 81, NA, 81, NA, NA, NA, 94, 74, 
                                      NA, 73, 75, NA, NA, 80, 89, 79, 84, 72, NA), label = &quot;Age at Followup 2 fasting blood/urine(yr&quot;), 
                 Q_AGEL = structure(c(88, NA, 87, NA, NA, 91, NA, 93, 83, 
                                      NA, 84, 78, 80, 75, 82, NA, 76, NA, 75, 76, 84, 78, NA, 75, 
                                      NA, NA, 94, 80, NA, NA, NA, 84, NA, 83, 94, NA, NA, NA, 78, 
                                      NA, 75, 78, NA, NA, NA, 92, 80, 87, 75, 89), label = &quot;Age at Followup 3 fasting blood/urine(yr&quot;), 
                 C_AGEL = structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                      NA, 90, NA, NA, NA, 87, NA, NA, NA, 81, NA, NA, NA, NA, 80, 
                                      NA, NA, NA, NA, NA, NA, NA, 89, NA, NA, 100, NA, NA, NA, 
                                      83, NA, NA, 84, NA, NA, NA, NA, 86, NA, 80, 94), label = &quot;Age at Followup 4 fasting blood/urine(yr&quot;), 
                 X_GPT = structure(c(20, 16, 11, 11, 12, 20, 16, 19, 32, 11, 
                                     13, 35, 15, 139, 14, 14, 20, 6, 10, 15, 11, 18, 10, 17, 15, 
                                     15, 15, 19, 49, 12, 13, 18, 9, 21, 12, 29, 29, 22, 22, 15, 
                                     23, 21, 10, 14, 20, 17, 18, 12, 24, 17), label = &quot;BL GPT (also known as ALT) (U/L)&quot;), 
                 Y_GPT = structure(c(13, NA, 14, 10, NA, 15, 17, NA, 25, 10, 
                                     10, 35, NA, 59, 12, 11, 20, NA, 11, 141, NA, 22, 9, 25, NA, 
                                     NA, 11, 10, NA, 10, 24, 19, NA, 10, NA, 16, NA, 9, 18, NA, 
                                     18, 20, NA, 12, NA, 13, 18, 11, 18, NA), label = &quot;F1 GPT (also known as ALT) (U/L)&quot;), 
                 Z_GPT = structure(c(12, 20, 16, NA, NA, 13, NA, 11, 24, NA, 
                                     6, 18, 18, 24, 15, NA, 17, NA, 16, 10, NA, 35, 8, 13, NA, 
                                     NA, 26, 11, NA, 14, NA, 17, NA, 17, NA, NA, NA, 11, 16, NA, 
                                     14, 20, NA, NA, 17, 11, 14, 8, 24, NA), label = &quot;F2 GPT (also known as ALT) (U/L)&quot;), 
                 Q_GPT = structure(c(16, NA, 19, NA, NA, 12, NA, 9, 21, NA, 
                                     10, 18, 18, 60, 13, NA, 18, NA, 12, 11, 11, 19, NA, 41, NA, 
                                     NA, 247, NA, NA, NA, NA, 16, NA, 12, 7, NA, NA, NA, 20, NA, 
                                     16, 18, NA, NA, NA, 14, 22, 18, 18, 34), label = &quot;F3 GPT (also known as ALT) (U/L)&quot;), 
                 C_GPT = structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                     12, NA, NA, NA, 12, NA, NA, NA, 15, NA, NA, NA, NA, 20, NA, 
                                     NA, NA, NA, NA, NA, NA, 23, NA, NA, 9, NA, NA, NA, 14, NA, 
                                     NA, 16, NA, NA, NA, NA, 24, NA, 18, 21), label = &quot;F4 GPT (also known as ALT) (U/L)&quot;, format.sas = &quot;BEST&quot;), 
                 X_GOT = structure(c(17, 17, 21, 15, 20, 20, 14, 26, 22, 21, 
                                     29, 26, 14, 90, 15, 20, 21, 12, 16, 9, 17, 19, 15, 22, 20, 
                                     19, 23, 22, 55, 21, 23, 22, 23, 16, 22, 19, 26, 23, 18, 15, 
                                     30, 23, 19, 15, 22, 23, 16, 20, 22, 24), label = &quot;BL GOT (also known as AST) (U/L)&quot;), 
                 Y_GOT = structure(c(12, NA, 13, 15, NA, 19, 16, NA, 25, 15, 
                                     24, 31, NA, 47, 12, 18, 17, NA, 20, 74, NA, 21, 12, 29, NA, 
                                     NA, 18, 16, NA, 18, 26, 21, NA, 15, NA, 18, NA, 13, 17, NA, 
                                     NA, 23, NA, 17, NA, 22, 18, 21, 21, NA), label = &quot;F1 GOT (also known as AST) (U/L)&quot;), 
                 Z_GOT = structure(c(8, 18, 21, NA, NA, 21, NA, 19, 21, NA, 
                                     24, 19, 14, 24, 14, NA, 19, NA, 19, 9, NA, 22, 12, 17, NA, 
                                     NA, 23, 15, NA, 18, NA, 25, NA, 11, NA, NA, NA, 13, 18, NA, 
                                     26, 22, NA, NA, 18, 21, 16, 23, 22, NA), label = &quot;F2 GOT (also known as AST) (U/L)&quot;), 
                 Q_GOT = structure(c(13, NA, 30, NA, NA, 21, NA, 19, 21, NA, 
                                     23, 18, 15, 53, 14, NA, 18, NA, 18, 8, 14, 21, NA, 30, NA, 
                                     NA, 311, NA, NA, NA, NA, 21, NA, 12, 20, NA, NA, NA, 21, 
                                     NA, 23, 22, NA, NA, NA, 22, 17, 28, 20, 36), label = &quot;F3 GOT (also known as AST) (U/L)&quot;), 
                 C_GOT = structure(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 
                                     25, NA, NA, NA, 15, NA, NA, NA, 18, NA, NA, NA, NA, 21, NA, 
                                     NA, NA, NA, NA, NA, NA, 29, NA, NA, 16, NA, NA, NA, 18, NA, 
                                     NA, 20, NA, NA, NA, NA, 19, NA, 20, 28), label = &quot;F4 GOT (also known as AST) (U/L)&quot;, format.sas = &quot;BEST&quot;), 
                 DATA_ULT = structure(c(17395, 13372, 15951, 11908, 11600, 
                                        15237, 12312, 14941, 16578, 12355, 15988, 17139, 16059, 15955, 
                                        15891, 15672, 15986, 10828, 16751, 15838, 16043, 15917, 13338, 
                                        16049, 13072, 13412, 14158, 14719, 11697, 14984, 13668, 17257, 
                                        11534, 15277, 16217, 16059, 13525, 13405, 17254, 11334, 14777, 
                                        16049, 11737, 12711, 13352, 14321, 15958, 16021, 15888, 16941
                 ), label = &quot;Date of Last Contact as of FUP4 or death&quot;, format.sas = &quot;DATE&quot;, class = &quot;Date&quot;), 
                 DECEASED = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 
                                        0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 
                                        1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1), 
                                      label = &quot;Deceased?/Deceduto(a)?&quot;)), row.names = c(NA,-50L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;))
  
  
  df.long &lt;- df %&gt;% pivot_longer(cols = c(ends_with(&quot;DATEL&quot;), ends_with(&quot;AGEL&quot;), ends_with(&quot;GPT&quot;), ends_with(&quot;GOT&quot;)), 
                                 names_to = c(&quot;time&quot;, &quot;.value&quot;), names_sep = &quot;(?&lt;=[XYZQC])_&quot;, values_drop_na = TRUE) %&gt;% 
    select(CODE98, DATEL, AGEL, GPT, GOT)
  
  df.merge &lt;- tmerge(df, df, id=CODE98, tstart=as.numeric(X_DATEL), tstop=as.numeric(DATA_ULT),
                     deceased=event(as.numeric(DATA_ULT), DECEASED))
  
  df.merge &lt;- tmerge(df.merge %&gt;% select(CODE98, id), df.long, 
                     id=CODE98,
                     age=tdc(as.numeric(DATEL), AGEL), 
                     gpt=tdc(as.numeric(DATEL), GPT), got=tdc(as.numeric(DATEL), GOT))
  </code></pre>
  <p>Can anybody understand what it is going on?
  Thanks so much in advance</p>