This is part Second of the R series. In the first part, we have discussed Introduction to R Programming and how to install R. In this part, we will discuss some of the basic commands that you required to initiate R.
Basic Syntax in R
1. Basic Command
2. Installing Packages
Let us start with some basic syntax of R. You can either use R Studio or R console to do the task. Here is initial line of code about how to remove all object stored in R:
- Remove all objects stored-
- Set Current Working Directory-
If you want to read files from a specific location you need to set working directory in R. The following example shows how to set the working directory in R to the folder”Set” within the folder “Data” on the D drive.
- Current working Directory-
- Installing Packages:
Packages are collections of well-defined functions and data in some required format. We can install packages according to our need. For package installation, we need an internet connection and we need to write this code:
Here I have written one package name for your reference
We have to install package only once and then we need to include its library. To include a library:
In this article, we have discussed the how to set the directory to proceed our work and how to install package.
Now, give it a try and we will discuss how to import different type of files in R in next article. If you have any doubt feel free to comment.