diff --git a/server_files/neutralsEdit.R b/server_files/neutralsEdit.R index 6863e1a..1bb5aeb 100644 --- a/server_files/neutralsEdit.R +++ b/server_files/neutralsEdit.R @@ -94,20 +94,19 @@ shiny::observeEvent( # Make copy of source directory neutralsOrigDir = file.path(neutralsSource,neutralsOrigVersion()) neutralsCopyDir = file.path(neutralsSource,neutralsCopyVersion()) - if(!dir.exists(neutralsCopyDir)) - dir.create(neutralsCopyDir) - files = list.files(path=neutralsOrigDir) - for(file in files) + if(!dir.exists(neutralsCopyDir)) { file.copy( from = file.path(neutralsOrigDir,file), to = file.path(neutralsCopyDir,file), - overwrite = TRUE + recursive = TRUE ) - id = shiny::showNotification( - h4(paste0('Created version: ', neutralsCopyVersion())), - closeButton = FALSE, - duration = 5 - ) + id = shiny::showNotification( + h4(paste0('Created new version: ', neutralsCopyVersion())), + closeButton = FALSE, + duration = 5 + ) + } + # Save modified file to target version data = isolate(input$ace) writeLines( @@ -119,5 +118,6 @@ shiny::observeEvent( closeButton = FALSE, duration = 5 ) + } ) diff --git a/server_files/neutralsParse.R b/server_files/neutralsParse.R index bd5ca1d..1b26241 100644 --- a/server_files/neutralsParse.R +++ b/server_files/neutralsParse.R @@ -33,6 +33,10 @@ observeEvent( { req(neutralsVersion()) + pasteNoNA = function(x) { + paste(x[!is.na(x)],collapse=" ") + } + nbReac = 0 reactants = products = params = type = orig = notes = list() @@ -41,7 +45,7 @@ observeEvent( file = file.path(neutralsSource,neutralsVersion(),filename), header = FALSE ) - comments = apply(scheme, 1, function(x) paste(x[15:length(x)],collapse=" ")) + comments = apply(scheme, 1, function(x) pasteNoNA(x[15:length(x)])) scheme = t(apply(scheme, 1, function(x) gsub(" ", "", x))) for (i in 1:nrow(scheme)) { if(substr(scheme[i,1],1,1)=='#') next @@ -63,7 +67,7 @@ observeEvent( file = file.path(neutralsSource,neutralsVersion(),filename), header = FALSE ) - comments = apply(scheme, 1, function(x) paste(x[25:length(x)],collapse=" ")) + comments = apply(scheme, 1, function(x) pasteNoNA(x[25:length(x)])) scheme = t(apply(scheme, 1, function(x) gsub(" ", "", x))) for (i in 1:nrow(scheme)) { if(substr(scheme[i,1],1,1)=='#') next @@ -86,7 +90,7 @@ observeEvent( file = file.path(neutralsSource,neutralsVersion(),filename), header = FALSE ) - comments = apply(scheme, 1, function(x) paste(x[15:length(x)],collapse=" ")) + comments = apply(scheme, 1, function(x) pasteNoNA(x[15:length(x)])) scheme = t(apply(scheme, 1, function(x) gsub(" ", "", x))) for (i in 1:nrow(scheme)) { if(substr(scheme[i,1],1,1)=='#') next @@ -109,7 +113,7 @@ observeEvent( file = file.path(neutralsSource,neutralsVersion(),filename), header = FALSE ) - comments = apply(scheme, 1, function(x) paste(x[25:length(x)],collapse=" ")) + comments = apply(scheme, 1, function(x) pasteNoNA(x[25:length(x)])) scheme = t(apply(scheme, 1, function(x) gsub(" ", "", x))) for (i in 1:nrow(scheme)) { if(substr(scheme[i,1],1,1)=='#') next @@ -135,7 +139,7 @@ observeEvent( header = FALSE, stringsAsFactors = FALSE ) - comments = apply(scheme, 1, function(x) paste(x[25:length(x)],collapse=" ")) + comments = apply(scheme, 1, function(x) pasteNoNA(x[25:length(x)])) scheme = t(apply(scheme, 1, function(x) gsub(" ", "", x))) for (i in 1:nrow(scheme)) { if(substr(scheme[i,1],1,1)=='#') next diff --git a/server_files/neutralsSample.R b/server_files/neutralsSample.R index 4df4fd8..5b6da58 100644 --- a/server_files/neutralsSample.R +++ b/server_files/neutralsSample.R @@ -243,7 +243,7 @@ output$plotRate = renderPlot({ par( mfrow = c(1, 2), - mar = c(3,3,8,2), + mar = c(3,3,9,2), mgp = gPars$mgp, tcl = gPars$tcl, lwd = gPars$lwd, @@ -273,7 +273,7 @@ output$plotRate = renderPlot({ side = 3, cex = 1.5, adj = 0, - line = 7, + line = 8, padj = 1, col = gPars$cols[1] )