Solucionar problemas con el exportado de volúmenes.

This commit is contained in:
2023-02-10 15:25:19 +01:00
parent e481ee411c
commit c416a850b5
+19 -8
View File
@@ -86,9 +86,14 @@ ui <- fluidPage(
) )
# Define server logic required to draw a histogram # Define server logic required to draw a histogram
server <- function(input, output) { server <- function(input, output) {
# Diseño ------------------------------------------------------------------
# Diseño # Diseño
dades<-reactiveValues() dades<-reactiveValues()
dades$taula<-NULL dades$taula<-NULL
@@ -340,7 +345,9 @@ server <- function(input, output) {
} }
) )
# Análisis
# Análisis ----------------------------------------------------------------
analysis<-reactiveValues() analysis<-reactiveValues()
analysis$taula<-NULL analysis$taula<-NULL
analysis$taula_def<-NULL analysis$taula_def<-NULL
@@ -350,11 +357,9 @@ server <- function(input, output) {
table<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T) table<-read.xlsx(input$file_analy$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T)
table$Date<-format(table$Date, format="%d/%m/%Y") table$Date<-format(table$Date, format="%d/%m/%Y")
if ("sex" %in% colnames(table)){table<-select(table, -sex)} if ("sex" %in% colnames(table)){table<-select(table, -sex)}
table$Long<-gsub(",",".", table$Long)
table$Wide<-gsub(",",".", table$Wide)
for (i in 1:nrow(table)){ for (i in 1:nrow(table)){
long<-as.numeric(strsplit(table[i,"Long"],"+", fixed = T)[[1]]) long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]]))
wide<-as.numeric(strsplit(table[i,"Wide"],"+", 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[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
} }
@@ -367,9 +372,12 @@ server <- function(input, output) {
table<-merge( table<-merge(
table %>% select(-Group), table %>% select(-Group),
table_group table_group
) %>% relocate(Group, .after = DayPostInoc) %>% arrange(DayPostInoc, Animal, Side) ) %>% relocate(Group, .after = DayPostInoc) %>%
relocate(Cage, .before = Animal) %>%
arrange(DayPostInoc, Animal, Side)
analysis$taula<-table analysis$taula<-table
print(table)
} }
}) })
output$cutoffUI<-renderUI({ output$cutoffUI<-renderUI({
@@ -615,11 +623,14 @@ server <- function(input, output) {
}, },
content = function(file){ content = function(file){
dtemplate<-analysis$taula dtemplate<-analysis$taula
write.xlsx(dtemplate,file) # print(str(dtemplate))
write.xlsx(dtemplate,file, )
} }
) )
##Exportar
# Exportar ----------------------------------------------------------------
output$expPlotUI<- renderUI({ output$expPlotUI<- renderUI({
observeEvent(analysis$taula, {}) observeEvent(analysis$taula, {})
if (!is.null(input$file_analy) & !is.null(analysis$taula)){ if (!is.null(input$file_analy) & !is.null(analysis$taula)){