Automate script execution R

Asked

Viewed 305 times

0

There is a script in the R link that works perfectly in Rstudio. To automate it, it runs every Tuesday at 15:00, I decided to create a file. bat and schedule its execution by the task scheduler, with the following commands:

"C:\Program Files\R\R-3.5.1\bin\Rscript.exe" --vanilla "H:\COP\00 - PROJETOS\06 - Carteira  (fase teste)\Testes Automacao\exportacaoPlanilhaBloomberg.R"

However, in the script there is a reference to an accented file, and when I run . bat, by cmd

`Erro: `path` does not exist: '//madreperola/GOP/COP/SALDO/SALDO FUNDO PREVIDENCIÃ?RIO.xlsm'`

I can not change the file name (BALANCE PENSION FUND.xlsm) because there are numerous other references to it, and not all made by me. Is there any other way to automate script execution, or resolve this issue without having to change the file name?

  • In the R script, the bat is just to run the same script!

1 answer

0

This is not a complete answer, but I think it can help you. I don’t use Windows, so I can’t properly test.

A possible solution to the accent problem:

Inside the R script, instead of you writing the path complete, try to give a paste0 with the setwd and get the file name via list.files(). When you give a list.files(), see his name, and if it is possible to use any regular expression rule in it.

A solution to the path itself:

Another thing: See that in the error output, the path begins with 2 bars: //, and not just /. See if this can’t be your mistake too.

I wrote here due to the character limit in the comment.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.