import data into r

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
 
library(foreign)
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”)

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”)

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;
run;

# in R
library(Hmisc)
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
 
 
 
 
 
For step by step procedure check this video.
 

 
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Releated

CCA

Canonical Correlation Analysis (CCA) using R

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Spread the love           Canonical correlation analysis (CCA) determines a set of canonical variates, orthogonal linear combinations of the variables within each set that best explain the variability both within and between sets. It is used to identify and measure the associations among two sets of variables. How to perform canonical correlation analysis in R? Follow this step […]