diff --git a/ebv_metadata_app.R b/ebv_metadata_app.R index 3aa3df5cebf82d367c4d414d8591c50522330b29..15587a3f41c6079165c37a7ab557d0965cb89375 100644 --- a/ebv_metadata_app.R +++ b/ebv_metadata_app.R @@ -292,6 +292,7 @@ ui <- fluidPage( "daily" = "P0000-00-01", 'one timestep' = "P0000-00-00", "irregular" = "Irregular", + "paleo" = "Paleo", "other" = "other"), width='80%'), @@ -551,11 +552,16 @@ server <- function(input, output) { } }) output$temporal_resoultion_irregular <- renderUI({ - if(input$temporal_resolution=='Irregular'){ - t <- renderText('Provide the definition of your timesteps as a comma-separated list in the format YYYY-MM-DD or short YYYY.') - - s <- textInput('temp_res_irr', '', width='80%', placeholder='YYYY, YYYY, ...') - return(list(t,s)) + if(input$temporal_resolution=='Irregular' | input$temporal_resolution=='Paleo'){ + if(input$temporal_resolution=='Irregular'){ + t <- renderText('Provide the definition of your timesteps as a comma-separated list in the format YYYY-MM-DD or short YYYY.') + s <- textInput('temp_res_irr', '', width='80%', placeholder='YYYY, YYYY, ...') + return(list(t,s)) + }else{ + t <- renderText('Provide the definition of your timesteps as a comma-separated list. The values will represent "kyr B.P.".') + s <- textInput('temp_res_irr', '', width='80%', placeholder='126, 125, ...') + return(list(t,s)) + } } }) @@ -566,7 +572,7 @@ server <- function(input, output) { #temporal extent---- output$temporal_extent <- renderUI({ - if(input$temporal_resolution!='Irregular'){ + if(input$temporal_resolution!='Irregular' & input$temporal_resolution!='Paleo'){ if(input$temporal_resolution=='other'){ #user defined temporal resolution if(grepl('^P{1}\\d{4}-00-00', input$temp_res_txt)){ @@ -926,15 +932,27 @@ server <- function(input, output) { to_do_list <- c(to_do_list, 'You chose "Irregular" temporal resolution and the input you provided does not match the required form: comma-separated YYYY-MM-DD or comma-separated YYYY. Please check.') create <- FALSE } - + } + if(input$temporal_resolution=='Paleo'){ + timestep_list <- stringr::str_split(input$temp_res_irr, ',')[[1]] + for(ts in timestep_list){ + if(is.na(suppressWarnings(as.numeric(ts)))){ + to_do_list <- c(to_do_list, paste0('You chose "paleo" temporal resolution. The value "', ts, '" does not seem to be a numeric value. Please check.')) + create <- FALSE + } + } } #temporal extent if(input$temporal_resolution=='Irregular'){ - timestep_list <- stringr::str_split(input$temp_res_irr, ',')[[1]] - ts_last <- length(timestep_list) - t_start <- timestep_list[1] - t_end <- timestep_list[ts_last]#last + timestep_list <- as.numeric(stringr::str_split(input$temp_res_irr, ',')[[1]]) + t_start <- min(timestep_list) + t_end <- max(timestep_list) + timesteps_irr <- paste0('"', paste0(timestep_list, collapse = '", "'), '"') + }else if(input$temporal_resolution=='Paleo'){ + timestep_list <- as.numeric(stringr::str_split(input$temp_res_irr, ',')[[1]]) + t_start <- max(timestep_list) + t_end <- min(timestep_list) timesteps_irr <- paste0('"', paste0(timestep_list, collapse = '", "'), '"') }else if(input$temporal_resolution=='P0000-00-00'){ t_start <-input$temporal_extent_input @@ -943,7 +961,7 @@ server <- function(input, output) { t_start <- input$temporal_extent_input[1] t_end <- input$temporal_extent_input[2] } - if(input$temporal_resolution!='Irregular'){ + if(input$temporal_resolution!='Irregular' & input$temporal_resolution!='Paleo'){ timesteps_irr <- '"N/A"' }