Data analysis in R | How to import data into R – Statistical Aid

Spread the love

Import data into R software is a easy process by which we can impots spss data set, stata data set, sas data set, excel, csv and other data set easily. R is a statistical analytics tool which free to use and it is a command based analytics tool.

Import data into R from SPSS

The importing procedure of data set into R is following-


  •  open R programm
  •  open a new script
  •  write the following code
  • Run the code

 Importing data from SPSS to R

Data_set <- read.spss(“data set location/data set name”, use.value.label=TRUE,

Importing data from Stata to R

# input Stata file
mydata <- read.dta(“c:/mydata.dta”)

Importing data from Excel to R

# first row contains variable names
mydata <- read.xlsx(“c:/myexcel.xlsx”, 1)

# read in the worksheet named mysheet
mydata <- read.xlsx(“c:/myexcel.xlsx”, sheetName = “mysheet”)

Importing data from csv file to R

# first row contains variable names, comma is separator
# assign the variable id to row names
# note the / instead of on mswindows systems

mydata <- read.table(“c:/mydata.csv”, header=TRUE,
   sep=”,”, row.names=”id”)

Importing data from SAS

# save SAS dataset in trasport format
libname out xport ‘c:/mydata.xpt’;
data out.mydata;
set sasuser.mydata;

# in R
mydata <- sasxport.get(“c:/mydata.xpt”)
# character variables are converted to R factors

R procedure

1. open R software
r software
2. Open new script
r console
3. Type the above code.


r editor
4. Run the code.


r data editor
Another contents (Data analysis using R) 
For step by step procedure check this video.


You cannot copy content of this page