R is the open source analytics software which everyone loves to use these days. Advantage of R over python is mostly easiness to use and adapt. Hence, we are starting the series of articles/ tutorials on R. This is first tutorial on R which talks about importing different types of datasets into R in different ways.
Importing CSV data into R using R console –
First, check for the default path of R using following command –
Now, set your own path of R for data default data libraries in R –
Once you set up this path, put your CSV dataset into that path you have set in above code. Then, write following command in R console to import the CSV dataset.
Importeddata <- read.csv(“forimport_data.csv”, header=T)
In above R command, ‘header = T’ signifies that first row will be with headers or titles of each column of CSV file.
Importing excel data into R using R console –
Here is the code to connect to Excel workbook and load excel files into R
Importeddata <- readWorksheetFromFile(“Input filename and the extension in this bracket”, sheet = 1)
Importing JSON files into R using R console –
Importeddata <- fromJSON(file = “Input filename here.json>” )
Importing XML data into R using R console –
importeddata <- xmlTreeParse(“<input URL of XML data here>”)
Importing SPSS and STATA files in R using R console-
Importeddata <- read.spss(“filename.sav”) //for SPSS//
Importeddata <- read.dta(“<Path of the file>”) //for STATA//
Importing SAS files in R using R console –
ImportedData <- read.sas7bdat(“filename.sas7bdat”)
Importing MiniTab files into R using R console –
ImportedData <- read.mtp(“filename.mtp”)
Importing any data into R using R studio –
Here is how you can import dataset of any type in R studio –
This is one of the reasons many people prefer R studio because it is extremely easy to use and does not require much programming.