Command Line versus Scripts
Execution of commands in R is not menu driven. (Not like Clicking over buttons to get outcome)
we need to type the commands.
Single line and multi line commands are possible to write.
When writing multi-line programs, it is useful to use a text editor rather than execute everything directly at the command line.
Option 1:
Execution of commands in R is not menu driven. (Not like Clicking over buttons to get outcome)
we need to type the commands.
Single line and multi line commands are possible to write.
When writing multi-line programs, it is useful to use a text editor rather than execute everything directly at the command line.
Option 1:
- One way use R's own built-in editor.
- It is accessible from the RGui menu bar.
- Click File and then click on New script.
At this point R will open a window entitled Untitled-R Editor.
We may type and edit in this.
It we want to execute a line or a group of lines, just highlight them and press Ctrl+R.
Option 2:
Use R studio software
Suppose we want to use following three functions:
Type them.
library (MASS)
attach (bacteria)
fix (bacteria)
Suppose we want to run only function: library (MASS)
Highlight it and click on Run.
Data Editor
- There is a data editor within R that can be accessed from the menu bar by selecting Edit/Data editor.
- Provide the name of the matrix or data frame that we want to edit and a Data Editor window appears.
- Alternatively we can do this from the command line using the fix function.
library (MASS)
attach (bacteria)
fix (bacteria)
We can do it in R Studio as follows :
Cleaning up the Windows
Cleaning up the Windows
- We assign names to variables when analyzing any data.
- It is good practice to remove the variable names give to any data frame at the end each session in R.
- This way, variable with same names but different properties will not get in each others way in subsequent work.
- rm ( ) command removes variable name
- For example,
rm (x, y, z) removes the variable x, y and z.
- detach ( ) command detaches objects from the Search Path.
- It removes it from the search ( ) path of available R objects.
- Usually this is either a data.frame which has been attached or a package which was attached by library.
- To get rid of everything, including data frames, type rm (list=1s( ) ).
0 Comments:
Post a Comment