boB Rudis
6 years ago
6 changed files with 57 additions and 3 deletions
@ -0,0 +1,32 @@ |
|||
#' Run a selection as an RStudio background job |
|||
#' |
|||
#' @export |
|||
enslave <- function() { |
|||
|
|||
ctx <- rstudioapi::getActiveDocumentContext() |
|||
|
|||
if (!is.null(ctx)) { |
|||
|
|||
if (ctx$selection[[1]]$text != "") { |
|||
|
|||
bits <- ctx$selection[[1]]$text |
|||
|
|||
tf <- tempfile(fileext = ".R") |
|||
writeLines(bits, con = tf) |
|||
|
|||
nm <- sprintf("enslaved_%s", gsub("\\-", "", uuid::UUIDgenerate())) |
|||
|
|||
.rs.api.runScriptJob( |
|||
path = tf, |
|||
workingDir = getwd(), |
|||
importEnv = TRUE, |
|||
exportEnv = nm |
|||
) |
|||
|
|||
message("Job started. Results will be in ", nm) |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,11 @@ |
|||
% Generated by roxygen2: do not edit by hand |
|||
% Please edit documentation in R/enslave.R |
|||
\name{enslave} |
|||
\alias{enslave} |
|||
\title{Run a selection as an RStudio background job} |
|||
\usage{ |
|||
enslave() |
|||
} |
|||
\description{ |
|||
Run a selection as an RStudio background job |
|||
} |
Loading…
Reference in new issue