Pergunta

I am writing a R script to run the commands in the front-end in ubuntu:

Rscript my_scripts.R  my_file.txt output_file

However, it gave me an error like "Error: unexpected symbol in "Rscript my_scripts.R"

I came upon this post R command line passing a filename to script in arguments (Windows). and I quote the answers "As I said in my comment, I would use Rscript instead of R CMD BATCH:"

So I found that in order to run this, I have to install

sudo apt-get install littler

according to this post Rscript on ubuntu

When I finished install this package, it still showed the same error message. Any solutions?

Best,

Foi útil?

Solução

Are you really running that from the unix shell prompt? Because I can get something like that error by typing that command at the R prompt:

$ R
  [startup noises]
> Rscript foo.r
Error: unexpected symbol in "Rscript foo.r"

Otherwise its something in your script that is similarly screwed up.

When run from the Unix command prompt, all is well:

$ Rscript test.R
[1] 1.414214

where test.R is simply print(sqrt(2))

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top