Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ggsurvplot internal error #1906

Closed
mmaughan0 opened this issue Jan 5, 2024 · 2 comments
Closed

ggsurvplot internal error #1906

mmaughan0 opened this issue Jan 5, 2024 · 2 comments

Comments

@mmaughan0
Copy link

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)
  10. │ ├─dplyr::dplyr_reconstruct(vec_slice(data, i), data)
  11. │ │ └─dplyr:::dplyr_new_data_frame(data)
  12. │ │ ├─row.names %||% .row_names_info(x, type = 0L)
  13. │ │ └─base::.row_names_info(x, type = 0L)
  14. │ └─vctrs::vec_slice(data, i)
  15. └─rlang:::stop_internal_c_lib(...)
  16. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)
@DavisVaughan
Copy link
Member

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
Copy link
Author

mmaughan0 commented Jan 12, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants