Question: I want to get the parent directory from a folder path.

say I have: "C:/Users/YS/2020 projects/APP/pect/PDC/src"

and I want to get: "C:/Users/YS/2020 projects/APP/pect/PDC"

```
#Get current directory
cpath = getwd()

#Remove last folder from path
dir <- strsplit(cpath,"/")
dir <- dir[[1]]
parent_dir <- dir[1:length(dir)-1]

#Return file path
file.path(parent_dir)

```

These are my environment variables:

[![enter image description here](https://i.stack.imgur.com/vJBo5.png)](https://i.stack.imgur.com/vJBo5.png)

and here is the output I get from the code:

```
[1] "C:"            "Users"         "YS"            "2020 projects" "APP"           "pect"          "PDC"    

```

I want it to return:

```
[1] "C:/Users/YS/2020 projects/APP/pect/PDC"

```

Why can't I pass a list of characters into file.path()?

I'm a little confused by how dir in my environment variables is listed as a character not a list or vector

I'm also a little confused by why strsplit returns a list with 1 value in it?

Answer: 
You can make `curr_date` reactive to the tabset:

```
library(shiny)

ui <- fluidPage(
  tabsetPanel(
    tabPanel(value = 'tab1', title = 'Data page',
             br(),
             actionButton("btn", "Refresh!"),
             br(),
             verbatimTextOutput("out")
    ),
    tabPanel(value = 'tab2', title = 'Other tab'),
    id = "tabset"
  )
)

server <- function(input, output, session) {
  curr_date <- eventReactive(list(input$btn, input$tabset), {
    req(input$tabset == 'tab1')
    format(Sys.time(), "%c")
  })

  output$out <- renderText({
    print(curr_date())
  })
}

shinyApp(ui, server)

```
You should use `reactiveValues()` and `observeEvent()` for this. Inside server function:

```
server <- function(input, output, session) {

  text_out <- reactiveValues(date = format(Sys.Date(), "%c"))

  observeEvent(input$btn, {
    text_out$date <- "something else"
  })

  output$out <- renderText({
     print(text_out$date)
}

```