Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
3 views
in R Programming by (3.5k points)
edited by

I have file called q.r and it has chmod of 755, how can I run it using a command-line?

sayHello <- function(){
   print('hey')
}
sayhey()

1 Answer

0 votes
by
edited by

To run an R script file directly from the UNIX command line, and print the output to the terminal, use the following command:

Rscript q.R

Note: The Rscript by default does not load the methods function. To load the methods function if your code relies on it, please load it explicitly on your script.

If you want to learn more about R programming watch this tutorial on Introduction to Data Science with R 

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...