diff --git a/invivos/app.R b/invivos/app.R index ea11a77..3f6c607 100755 --- a/invivos/app.R +++ b/invivos/app.R @@ -411,7 +411,21 @@ server <- function(input, output) { table$Group<-factor(table$Group, levels=levels) table<-filter(table, !is.na(Group)) }else(table$Group<-factor(table$Group)) - print(str(table)) + + + if (input$increase_volume){ + cols<-colnames(table) + timepoints<-unique(table$DayPostInoc) + table_old<-select(table, -Volume) + table_vols<-table %>% + select(-Weight, -Date, -Long, -Wide,-Observations) %>% + spread(DayPostInoc, Volume) %>% + mutate(across(all_of(as.character(timepoints)), function(x){(x*100/`0`)-100})) %>% + gather(DayPostInoc, Volume, all_of(as.character(timepoints))) %>% + mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume)) + table<-merge(table_old, table_vols)[,cols] + } + analysis$taula<-table } }) @@ -431,14 +445,6 @@ server <- function(input, output) { table<-analysis$taula table<-table %>% filter(!is.na(Group)) - if (input$increase_volume){ - timepoints<-unique(table$Timepoint) - table<-table %>% select(-Major, -Minor) %>% - spread(Timepoint, Volume) %>% - mutate(across(all_of(timepoints), function(x){(x*100/`0`)-100})) %>% - gather(Timepoint, Volume, -`ID animal`, -`ID tumor`, -Group) %>% - mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume)) - } table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n) } })