#' prism_output
#' @export prism_output
#'
prism_output <- function(tranformed_data) {
tmp <- tranformed_data %>%
pivot_wider(
id_cols = c(Type, Treatment, SubjectID, Dose),
names_from = Time,
values_from = Response_Transformed
) %>%
tail(22)
max_n <- tmp %>%
group_by(Type, Treatment, Dose) %>%
summarize(n = n()) %>%
ungroup() %>%
slice_max(n, with_ties = FALSE) %>%
select(n) %>%
unlist()
prism <- map_df(.x = unique(tmp$Treatment), .f = ~ {
out <- tmp %>%
filter(Treatment == .x) %>%
mutate(SubjectID = paste("SubjectID", row_number()))
if (nrow(out) < max_n) {
diff <- max_n - nrow(out)
trt_add <- distinct(.data = out, Type, Treatment, Dose)
for (i in 1:diff) {
out <- out %>%
bind_rows(data.frame(trt_add,
SubjectID = paste("SubjectID", i + nrow(out))
))
}
}
return(out)
}) %>%
as.matrix() %>%
t()
rownames(prism)[2] <- ""
rownames(prism)[1] <- "Timepoint"
return(prism)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.