Writing Scripts of Codes in R | R for Beginners

Published: 23 March 2023
on channel: Animal Sciences
5,626
27

In this video, we will learn how to write and execute scripts of code in R. R script is a text file that can be used to store R commands and functions. To open the script file in rstudio, click on file, then new file and here click on R script. Alternatively, you can press CTRL + Shift + N from the keyboard to open R script file. So, Why do we need R script file?
R script file can be used to save and reuse codes. The codes in R script file can be shared with anyone. And the important thing about r scripts is that it allows us to add comments on the use of codes. So, you can reuse these codes effectively.
You can open an existing r script file by clicking on the file and then open file. Here you can select an existing file and open it. A # symbol is used for comment line. It will let R know that this line is not the code and it is simply text.
To execute or run a code, bring your cursor to the line of code which you wan to execute and click on run. Alternatively, you can simply press CTRL + ENTER to run a piece of code. You can see a new object x is created in the environment.
You can also run multiple lines of code at once by selecting all of them and then clicking on run. Or by pressing key board shortcut Ctrl + Enter.
The R script files are saved with .R extension. To save this script, place the cursor on script and click on file and click on save. You can save this file with any name. Alternatively, you can press keyboard shortcut Ctrl + S to save the script.

To learn basics of R Programming
   • Basics of R Programing  

#rscript #rcodes #rprogrammingforbeginners #rprogramming #rstats #animalsciences


Watch video Writing Scripts of Codes in R | R for Beginners online without registration, duration hours minute second in high quality. This video was added by user Animal Sciences 23 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 5,626 once and liked it 27 people.