Browse Source

Cortar gráficos cuando hay una operación.

master
marcelcosta 1 year ago
parent
commit
0e4ef399fd
1 changed files with 37 additions and 0 deletions
  1. +37
    -0
      invivos/app.R

+ 37
- 0
invivos/app.R

@ -46,6 +46,7 @@ ui <- fluidPage(
uiOutput('cutoffUI'),
checkboxInput("filter_stats","Filtrar Estadística"),
checkboxInput("increase_volume","Usar Incremento de Volumen"),
checkboxInput("operated","Cortar al operar", value = TRUE),
downloadButton("downloadVolume", "Descargar Volúmenes")
),
mainPanel(
@ -448,7 +449,18 @@ server <- function(input, output) {
Observations=""
)
table<-rbind(table, basal)
if (input$vacc == "Sí"){
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
select(DayPostInoc, Side) %>% unique() %>%
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
if (input$operated == TRUE){
for (i in 1:nrow(firstoper)){
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
}
}
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
geom_errorbar(stat="summary", width=0.05)+
geom_line(stat="summary")+
@ -459,6 +471,15 @@ server <- function(input, output) {
scale_x_continuous(expand = expansion(mult = c(0,0.05)), limits = c(0, (round(max(table$DayPostInoc) / 5)+1)*5))+
theme_bw()
}else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (input$operated == TRUE){
table<-table %>% filter(DayPostInoc < firstoper)
}
ggplot(table, aes(DayPostInoc, Volume, color=Group, group=Group))+
geom_errorbar(stat="summary",width=0.05)+
geom_line(stat="summary")+
@ -681,6 +702,15 @@ server <- function(input, output) {
if (input$fig_id %in% c("Cinética Grupo", "Cinética Individual")){
if (input$fig_id == "Cinética Grupo"){
if (input$vacc == "Sí"){
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
select(DayPostInoc, Side) %>% unique() %>%
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
if (input$operated == TRUE){
for (i in 1:nrow(firstoper)){
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
}
}
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
errbar<-table %>% group_by(Group,Side,DayPostInoc) %>%
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%
@ -700,6 +730,13 @@ server <- function(input, output) {
geom_segment(data=errbar, aes(y=mean+std, yend=mean+std,
x=x,xend=xend))
}else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (input$operated == TRUE){
table<-table %>% filter(DayPostInoc < firstoper)
}
std<-function(x, na.rm=T){sd(x, na.rm=na.rm)/sqrt(length(x))}
errbar<-table %>% group_by(Group, DayPostInoc) %>%
summarise(mean=mean(Volume, na.rm=T), std=std(Volume)) %>%

Loading…
Cancel
Save