Functions for the future vtools package
deploy_app <- function(folder = basename(getwd()), user = Sys.info()[["user"]]) {
command <- sprintf("sudo cp -R /home/%s/%s /srv/shiny-server",
user,
folder)
system(command)
print(sprintf("app %s deployed", folder))
}
remove_app <- function(app) {
command <- sprintf("sudo rm -r /../srv/shiny-server/%s",
app)
system(command)
}
df_to_ts <- function(df) {
new_ts <- xts::xts(x = df[, 2:(length(colnames(df)))], order.by = df[[1]])
if (is.null(colnames(new_ts))) {
colnames(new_ts) <- colnames(df[2])
}
new_ts
}
ts_to_df <- function(tseries){
require(xts)
require(dplyr)
new_df <- as_tibble(data.frame(datetime=index(tseries), coredata(tseries)))
}
source_to_envir <- function(file){
e <- new.env()
source(file, local = e)
e
}