#' Quickly open some documents.
#' @author Jiaxiang Li
#'
#' @import rstudioapi
#' @importFrom stringr str_subset
#' @import purrr
#' @import tibble
#' @importFrom dplyr filter
#' @export
open_file <- function(){
if_open <- function(x){
if (file.exists(x)) {
rstudioapi::navigateToFile(x)
}
}
a_rmd <-
list.files() %>%
stringr::str_subset("a\\d+\\.Rmd") %>%
max()
current_modified_file <-
dir() %>%
file.info %>%
tibble::rownames_to_column() %>%
dplyr::filter(rowname %>% str_detect("\\.Rmd$")) %>%
filter(
mtime == max(mtime)
) %>%
.[1,1]
open_list <- c("NEWS.md",a_rmd,current_modified_file)
if (length(open) > 0) {
purrr::map(open_list,if_open)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.