r-lib / vctrs

Generic programming with typed R vectors
https://vctrs.r-lib.org
Other
282 stars 65 forks source link

ggsurvplot internal error #1906

Closed mmaughan0 closed 6 months ago

mmaughan0 commented 6 months ago

Reprex code: library(heemod) library(flexsurv) library(rgho) library(survival) library(ggplot2)

install.packages("survival") install.packages("survminer") install.packages("dpylr")

par_mod <- define_parameters(

age_base = 30*365,##cycle in this model is 1 day

age_cycle = model_time + age_base)

put more comments in code

par_mod <- define_parameters(

p_death_disease_base = compute_surv( fit_death_disease_base, time = state_time, km_limit = 14))

par_mod <- modify( par_mod,

p_death_disease_mAb = compute_surv( fit_death_disease_mAb, time = state_time, km_limit = 14))

tab_surv_base <- structure(list(time = c(1,1,2,3,5,5,6,6,7,7,8,9, 10, 14, 14 ), status = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = c("time", "status"), row.names = c(NA, -14L), class = "data.frame")

ggsurvplot(tab_surv_base)

Error: Error in vec_slice(): ! Column time (size 15) must match the data frame (size 14). ℹ In file slice.c at line 188. ℹ Install the winch package to get additional debugging info the next time you get this error. ℹ This is an internal error that was detected in the vctrs package. Please report it at https://github.com/r-lib/vctrs/issues with a reprex and the full backtrace. Backtrace: ▆

  1. ├─survminer::ggsurvplot(tab_surv_base)
  2. │ ├─base::do.call(ggsurvplot_df, opts_df)
  3. │ └─survminer (local) <fn>(...)
  4. │ └─survminer:::.connect2origin(df)
  5. │ └─d %>% dplyr::distinct(strata, .keep_all = TRUE)
  6. ├─dplyr::distinct(., strata, .keep_all = TRUE)
  7. ├─dplyr:::distinct.data.frame(., strata, .keep_all = TRUE)
  8. │ ├─dplyr::dplyr_row_slice(out, loc)
  9. │ └─dplyr:::dplyr_row_slice.data.frame(out, loc)
    1. │ ├─dplyr::dplyr_reconstruct(vec_slice(data, i), data)
    2. │ │ └─dplyr:::dplyr_new_data_frame(data)
    3. │ │ ├─row.names %||% .row_names_info(x, type = 0L)
    4. │ │ └─base::.row_names_info(x, type = 0L)
    5. │ └─vctrs::vec_slice(data, i)
    6. └─rlang:::stop_internal_c_lib(...)
    7. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)
DavisVaughan commented 6 months ago

In tab_surv_base, your time column has 15 elements, but you've declared the number of rows as 14.

This is an invalid / corrupt data frame, and there is nothing vctrs can do to support that. You'll need to fix that one on your end, or, if this data object came from another package, report the issue upstream to them

mmaughan0 commented 6 months ago

Thanks!

On Fri, Jan 12, 2024 at 9:25 AM Davis Vaughan @.***> wrote:

In tab_surv_base, your time column has 15 elements, but you've declared the number of rows as 14.

This is an invalid / corrupt data frame, and there is nothing vctrs can do to support that. You'll need to fix that one on your end, or, if this data object came from another package, report the issue upstream to them

— Reply to this email directly, view it on GitHub https://github.com/r-lib/vctrs/issues/1906#issuecomment-1889348327, or unsubscribe https://github.com/notifications/unsubscribe-auth/BFEKOFJAHNLJAPZOAEX3OJ3YOFBXBAVCNFSM6AAAAABBOT2Y52VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBZGM2DQMZSG4 . You are receiving this because you authored the thread.Message ID: @.***>