0

I have a script that I have to modify manually to process each day. I have to change a few lines of code to modify a single number (a day to process). This causes some headache since I need to keep track of the changes. I process say 5 scripts at any one time using the following in the command line:

RScript /path/to/my/script/myRScript.R.

Then I have to go back and re-modify the script to process another day... Run the script again in the terminal.

I am trying to create a Shiny app which takes a day as input and then when the button is clicks it modifies the corresponding line in the RScript, then executes the RScript. I know some bash or chron job would work but I think it would be simpler to click a button and visually modify the RScript.

Shiny script:

library(shiny)

ui <- fluidPage(

titlePanel("Old Faithful Geyser Data"),


sidebarLayout(
    sidebarPanel(
      shiny::numericInput(inputId = "THIS_NUMBER", label = "Enter day to modify", value = 0),
      shiny::actionButton(inputId = "ModifyRScript", label = "Clicking this will modify the R Script!")
    ),


)

)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)

R Script:

setwd("/home/user/Apps/executeRScript/")


library(tidyverse)
iris %>% 
  mutate(
    rowID = row_number()
  ) %>% 
  pivot_wider(names_from = Species, values_from = c(Sepal.Length:Petal.Width)) %>% 
  write_csv("./myData.csv")

print(paste("This script is executed after clicking the shiny button"))
print(paste("There are some things to modify in the script", THIS_NUMBER, sep = " "))

# I actually want to modify this line
# write_csv("./myData_2022_10_21.csv")
# To be write_csv(paste("./myData_2022_10_", THIS_NUMBER, ".csv")
user113156
  • 6,761
  • 5
  • 35
  • 81

0 Answers0