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
library(foreign)
Data_set <- read.spss(“data set location/data set name”, use.value.label=TRUE, to.data.frame=TRUE)
Data_set
Data_set <- read.spss(“data set location/data set name”, use.value.label=TRUE, to.data.frame=TRUE)
Data_set
Importing data from Stata to R
# input Stata file
library(foreign)
mydata <- read.dta(“c:/mydata.dta”)
library(foreign)
mydata <- read.dta(“c:/mydata.dta”)
Importing data from Excel to R
# first row contains variable names
library(xlsx)
mydata <- read.xlsx(“c:/myexcel.xlsx”, 1)
# read in the worksheet named mysheet
mydata <- read.xlsx(“c:/myexcel.xlsx”, sheetName = “mysheet”)
library(xlsx)
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”)
# 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;
run;
# in R
library(Hmisc)
mydata <- sasxport.get(“c:/mydata.xpt”)
# character variables are converted to R factors
libname out xport ‘c:/mydata.xpt’;
data out.mydata;
set sasuser.mydata;
run;
# in R
library(Hmisc)
mydata <- sasxport.get(“c:/mydata.xpt”)
# character variables are converted to R factors
R procedure
1. open R software
2. Open new script
3. Type the above code.
4. Run the code.
Another contents (Data analysis using R)
Import data into R
Principal component analysis (PCA) code
canonical correlation analysis (CCA) code
Independent component analysis (ICA) code
Cluster Analysis using R
One-way ANOVA using R
Two-way ANOVA using R
Paired sample t-test using R
One sample T-test using R
Random forest in R
Chi-square test in R
Pearson correlation test in R
Principal component analysis (PCA) code
canonical correlation analysis (CCA) code
Independent component analysis (ICA) code
Cluster Analysis using R
One-way ANOVA using R
Two-way ANOVA using R
Paired sample t-test using R
One sample T-test using R
Random forest in R
Chi-square test in R
Pearson correlation test in R
For step by step procedure check this video.