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

fix: require mydata for profiles_per_patient calculation #175

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions inst/shiny/tabs/nca.R
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,24 @@ output$datatable <- renderReactable({

# IN this tab we can set the dose number to be analyzed, the extrapolation
# method, potenital partial AUC and all the flag rule sets

# Define the profiles (dosno) associated with each patient (usubjid) for the selected analyte
profiles_per_patient <- reactiveVal(NULL)
observeEvent(mydata(), {
profiles_per_patient(tapply(mydata()$conc$data$DOSNO, mydata()$conc$data$USUBJID, unique))
# Define a profiles per patient
profiles_per_patient <- reactive({
req(mydate())

# Check if res_nca() is available and valid
if (!is.null(res_nca())) {
res_nca()$result %>%
mutate(USUBJID = as.character(USUBJID),
DOSNO = as.character(DOSNO)) %>%
group_by(USUBJID, ANALYTE, PCSPEC) %>%
summarise(DOSNO = unique(DOSNO), .groups = "drop") %>%
unnest(DOSNO) # Convert lists into individual rows
} else {
mydata()$conc$data %>%
mutate(USUBJID = as.character(USUBJID)) %>%
group_by(USUBJID, ANALYTE, PCSPEC) %>%
summarise(DOSNO = list(unique(DOSNO)), .groups = "drop")
}
})

# Include keyboard limits for the settings GUI display
Expand Down
Loading