diff --git a/invivos/app.R b/invivos/app.R index d73bab3..e82193f 100755 --- a/invivos/app.R +++ b/invivos/app.R @@ -121,12 +121,17 @@ server <- function(input, output) { } table$Date<-format(table$Date, format="%d/%m/%Y") if ("sex" %in% colnames(table)){table<-select(table, -sex)} - for (i in 1:nrow(table)){ - long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]])) - wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]])) - table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6))) + if ("Abs" %in% colnames(table)){ + table<-rename(table, "Volume"="Abs") + }else{ + for (i in 1:nrow(table)){ + long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]])) + wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]])) + table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6))) + } + table$Volume<-as.numeric(table$Volume) } - table$Volume<-as.numeric(table$Volume) + if ("Cage" %in% colnames(table)){ table$Animal<-paste0(table$Cage, table$Animal) table<-table[,-which(colnames(table) == "Cage")] @@ -194,6 +199,7 @@ server <- function(input, output) { grafic<-eventReactive(input$goButton,{ df<-dades$taula %>% filter(DayPostInoc == input$day_vol) df<-df[!is.na(df$Volume),] + print(df) up_cuttof<-input$upcut low_cuttof<-input$lowcut