How to save everything from Console to a text file while executing an R script using “remoteScript” of Microsoft R?










0















I'm curious to know if there is a way to save everything from the R console to a text file when an R script is submitted and executed "remotely" from Microsoft R client to Microsoft R server using the command remoteScript() or remoteExecute().



For example, consider a simple R script 'test.R' as follows:



set.seed(123)
x <- rnorm(100)
mean(x)


I know, to save all from the console, it can be executed in a Local R session as follows:



Local R session:



# Create a text file to save all from console 
logfile <- file("C:/.../MyLog1.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the local R session
source("C:/.../test.R", echo = TRUE, max.deparse.length = 1000000)

sink()
sink(type = "message")


The log file 'MyLog1.txt', as expected, has everything from the console:



> set.seed(123)
> x <- rnorm(100)
> mean(x)
[1] 0.09040591


Similarly, the same script can be executed with remoteScript() after connecting to the R server.



Remote R session:



# Connect to the server and create a remote session
remoteLogin(...)

# Go back to the local R session
pause()

# Create a text file to save all from console
logfile <- file("C:/.../MyLog2.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the remote R session
remoteScript("C:/.../test.R")

sink()
sink(type = "message")


But the log file 'MyLog2.txt' looks different, as shown below:



[1] 0.09040591
$success
[1] TRUE

$errorMessage
[1] ""

$outputParameters
list()

$consoleOutput
[1] "[1] 0.09040591rn"

$changedFiles
list()

$backgroundUpdate
[1] 0


It has only the "Output" and some additional information. Each line of the code with '>' command prompt was not printed like 'MyLog1.txt'. It may be because there is no option like echo=TRUE for remoteScript().



Can anybody help me out with any alternative?



Thanks..










share|improve this question






















  • Have you seen How to save all console output to file in R? Note the comments in particular.

    – G5W
    Nov 12 '18 at 21:29












  • Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

    – Arijit
    Nov 14 '18 at 6:43
















0















I'm curious to know if there is a way to save everything from the R console to a text file when an R script is submitted and executed "remotely" from Microsoft R client to Microsoft R server using the command remoteScript() or remoteExecute().



For example, consider a simple R script 'test.R' as follows:



set.seed(123)
x <- rnorm(100)
mean(x)


I know, to save all from the console, it can be executed in a Local R session as follows:



Local R session:



# Create a text file to save all from console 
logfile <- file("C:/.../MyLog1.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the local R session
source("C:/.../test.R", echo = TRUE, max.deparse.length = 1000000)

sink()
sink(type = "message")


The log file 'MyLog1.txt', as expected, has everything from the console:



> set.seed(123)
> x <- rnorm(100)
> mean(x)
[1] 0.09040591


Similarly, the same script can be executed with remoteScript() after connecting to the R server.



Remote R session:



# Connect to the server and create a remote session
remoteLogin(...)

# Go back to the local R session
pause()

# Create a text file to save all from console
logfile <- file("C:/.../MyLog2.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the remote R session
remoteScript("C:/.../test.R")

sink()
sink(type = "message")


But the log file 'MyLog2.txt' looks different, as shown below:



[1] 0.09040591
$success
[1] TRUE

$errorMessage
[1] ""

$outputParameters
list()

$consoleOutput
[1] "[1] 0.09040591rn"

$changedFiles
list()

$backgroundUpdate
[1] 0


It has only the "Output" and some additional information. Each line of the code with '>' command prompt was not printed like 'MyLog1.txt'. It may be because there is no option like echo=TRUE for remoteScript().



Can anybody help me out with any alternative?



Thanks..










share|improve this question






















  • Have you seen How to save all console output to file in R? Note the comments in particular.

    – G5W
    Nov 12 '18 at 21:29












  • Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

    – Arijit
    Nov 14 '18 at 6:43














0












0








0








I'm curious to know if there is a way to save everything from the R console to a text file when an R script is submitted and executed "remotely" from Microsoft R client to Microsoft R server using the command remoteScript() or remoteExecute().



For example, consider a simple R script 'test.R' as follows:



set.seed(123)
x <- rnorm(100)
mean(x)


I know, to save all from the console, it can be executed in a Local R session as follows:



Local R session:



# Create a text file to save all from console 
logfile <- file("C:/.../MyLog1.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the local R session
source("C:/.../test.R", echo = TRUE, max.deparse.length = 1000000)

sink()
sink(type = "message")


The log file 'MyLog1.txt', as expected, has everything from the console:



> set.seed(123)
> x <- rnorm(100)
> mean(x)
[1] 0.09040591


Similarly, the same script can be executed with remoteScript() after connecting to the R server.



Remote R session:



# Connect to the server and create a remote session
remoteLogin(...)

# Go back to the local R session
pause()

# Create a text file to save all from console
logfile <- file("C:/.../MyLog2.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the remote R session
remoteScript("C:/.../test.R")

sink()
sink(type = "message")


But the log file 'MyLog2.txt' looks different, as shown below:



[1] 0.09040591
$success
[1] TRUE

$errorMessage
[1] ""

$outputParameters
list()

$consoleOutput
[1] "[1] 0.09040591rn"

$changedFiles
list()

$backgroundUpdate
[1] 0


It has only the "Output" and some additional information. Each line of the code with '>' command prompt was not printed like 'MyLog1.txt'. It may be because there is no option like echo=TRUE for remoteScript().



Can anybody help me out with any alternative?



Thanks..










share|improve this question














I'm curious to know if there is a way to save everything from the R console to a text file when an R script is submitted and executed "remotely" from Microsoft R client to Microsoft R server using the command remoteScript() or remoteExecute().



For example, consider a simple R script 'test.R' as follows:



set.seed(123)
x <- rnorm(100)
mean(x)


I know, to save all from the console, it can be executed in a Local R session as follows:



Local R session:



# Create a text file to save all from console 
logfile <- file("C:/.../MyLog1.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the local R session
source("C:/.../test.R", echo = TRUE, max.deparse.length = 1000000)

sink()
sink(type = "message")


The log file 'MyLog1.txt', as expected, has everything from the console:



> set.seed(123)
> x <- rnorm(100)
> mean(x)
[1] 0.09040591


Similarly, the same script can be executed with remoteScript() after connecting to the R server.



Remote R session:



# Connect to the server and create a remote session
remoteLogin(...)

# Go back to the local R session
pause()

# Create a text file to save all from console
logfile <- file("C:/.../MyLog2.txt")
sink(logfile, append = TRUE)
sink(logfile, append = TRUE, type = "message")

# Execute in the remote R session
remoteScript("C:/.../test.R")

sink()
sink(type = "message")


But the log file 'MyLog2.txt' looks different, as shown below:



[1] 0.09040591
$success
[1] TRUE

$errorMessage
[1] ""

$outputParameters
list()

$consoleOutput
[1] "[1] 0.09040591rn"

$changedFiles
list()

$backgroundUpdate
[1] 0


It has only the "Output" and some additional information. Each line of the code with '>' command prompt was not printed like 'MyLog1.txt'. It may be because there is no option like echo=TRUE for remoteScript().



Can anybody help me out with any alternative?



Thanks..







r console microsoft-r r-server






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 21:12









ArijitArijit

1




1












  • Have you seen How to save all console output to file in R? Note the comments in particular.

    – G5W
    Nov 12 '18 at 21:29












  • Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

    – Arijit
    Nov 14 '18 at 6:43


















  • Have you seen How to save all console output to file in R? Note the comments in particular.

    – G5W
    Nov 12 '18 at 21:29












  • Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

    – Arijit
    Nov 14 '18 at 6:43

















Have you seen How to save all console output to file in R? Note the comments in particular.

– G5W
Nov 12 '18 at 21:29






Have you seen How to save all console output to file in R? Note the comments in particular.

– G5W
Nov 12 '18 at 21:29














Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

– Arijit
Nov 14 '18 at 6:43






Yes. I'm using remoteScript() instead of source() to run the script in a remote server. But the result is not the same - only output line is printed, input lines are not printed.

– Arijit
Nov 14 '18 at 6:43













0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270194%2fhow-to-save-everything-from-console-to-a-text-file-while-executing-an-r-script-u%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53270194%2fhow-to-save-everything-from-console-to-a-text-file-while-executing-an-r-script-u%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Use pre created SQLite database for Android project in kotlin

Darth Vader #20

Ondo