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
[ Ссылка ]
#rscript #rcodes #rprogrammingforbeginners #rprogramming #rstats #animalsciences
Writing Scripts of Codes in R | R for Beginners
Теги
r codesr scriptscript file in ropen r scriptlearn coding in rrstudio codesbasics of r programmingobjects in rrstudiorstatsr for data analysislearn r programmingstatistics in rcoding in rr for data sciencewrite codecoding for beginnersprogramming for beginnerscomments on codescoding rulescomment line in rrun codenuman sharifanimal sciencesdata analysis in r