This is the R Script for reactable output. I saved it
with a name reactable_editRscript.R.
Now I would like to modify the reactable_editRscript.R,
and save it with a different name, maybe
reactable_editRscript_2023-04-20.R.
orgfile <- file("reactable_editRscript.R", open = "r")
content <- readLines(orgfile)
line_num_cat(content)## 1: out <- function(){
## 2: data <- MASS::Cars93
## 3: data <- data[data$Make != "Mazda RX-7", ]
## 4: data$Manufacturer[data$Manufacturer == "Chrylser"] <- "Chrysler"
## 5: data$Manufacturer <- as.character(data$Manufacturer )
## 6: data$Make <- as.character(data$Make)
## 7: data$Cylinders <- as.numeric(data$Cylinders)
## 8: summary_dt <- data %>% group_by(Manufacturer) %>% arrange(desc(Max.Price)) %>% slice(1)
## 9: summary_dt <- summary_dt[, c("Manufacturer","Make","Price",
## 10: "MPG.city", "MPG.highway", "Type",
## 11: "EngineSize", "Horsepower","Cylinders",
## 12: "Length", "Width",
## 13: "Weight")]
## 14: summary_dt$type_col <- ifelse(summary_dt$Type == "Small",'#011936',
## 15: ifelse(summary_dt$Type == "Midsize",'#465362',
## 16: ifelse(summary_dt$Type == "Large",'#82A3A1',
## 17: ifelse(summary_dt$Type =="Van",'#9FC490','#C0DFA1'))))
## 18: data <- data[,c("Manufacturer", "Make","Price","MPG.city","MPG.highway","Horsepower")]
# You can use line number to change
content[15] <- "ifelse(summary_dt$Type == 'Midsize','red',"
# You can use gsub to replace
content <- gsub('#82A3A1','green',content)
# Save the file with different name
fileConn <- file(paste0("reactable_editRscript_",Sys.Date(),".R"))
writeLines(content, fileConn)
close(fileConn)