in R Language by
Import Data into R: Read CSV, Excel, SPSS, Stata, SAS Files

1 Answer

0 votes

Read CSV

One of the most widely data store is the .csv (comma-separated values) file formats. R loads an array of libraries during the start-up, including the utils package. This package is convenient to open csv files combined with the reading.csv() function. Here is the syntax for read.csv

read.csv(file, header = TRUE, sep = ",")

Read Excel files

Excel files are very popular among data analysts. Spreadsheets are easy to work with and flexible. R is equipped with a library readxl to import Excel spreadsheet.

Use this code


Read sas

For our example, we are going to use the admission dataset from IDRE.

PATH_sas <- ''
df <- read_sas(PATH_sas)


For STATA data files you can use read_dta(). We use exactly the same dataset but store in .dta file.

PATH_stata <- ''
df <- read_dta(PATH_stata)


We use the read_sav()function to open a SPSS file. The file extension ".sav"

PATH_spss <- ''
df <- read_sav(PATH_spss)

Related questions

0 votes
asked Nov 6, 2019 in R Language by MBarbieri
+2 votes
asked Jul 28, 2019 in R Language by Aarav2017
+2 votes
asked Jul 28, 2019 in R Language by Aarav2017