Introduction
Importing data into R is a necessary step that, at times, can become time intensive. To ease this task, the RStudio IDE includes new features to import data from: csv, xls, xlsx, sav, dta, por, sas and stata files.

Importing data
The data import features can be accessed from the environment pane or from the tools menu. The importers are grouped into 3 categories: Text data, Excel data and statistical data. To access this feature, use the "Import Dataset" dropdown from the "Environment" pane:

Or through the "File" menu, followed by the "Import Dataset" submenu:

Importing data from Text and CSV files
Importing "From Text (readr)" files allows you to import CSV files and in general, character delimited files using the readr package. This Text importer provides support to:
- Import from the file system or a url
- Change column data types
- Skip or include-only columns
- Rename the data set
- Skip the first N rows
- Use the header row for column names
- Trim spaces in names
- Change the column delimiter
- Encoding selection
- Select quote, escape, comment and NA identifiers
For example, one can import with ease a csv form data.gov by pasting this url https://data.montgomerycountymd.gov/api/views/2qd6-mr43/rows.csv?accessType=DOWNLOAD and selecting "Import".

Importing data from Text files
Importing using "From Text (base)" enables importing text files using the base package, this is helpful to preserve compatibility with previous versions of RStudio.

Importing data from Excel files
The Excel importer provides support to:
- Import from the file system or a url
- Change column data types
- Skip columns
- Rename the data set
- Select an specific Excel sheet
- Skip the first N rows
- Select NA identifiers
For example, one can import with ease an xls file from data.gov by pasting this url http://www.fns.usda.gov/sites/default/files/pd/slsummar.xls and selecting "Update".
Notice that this file contains to tables and therefore, requires the first few rows to be removed.

We can clean this up by skipping 6 rows from this file and unchecking the "First Row as Names" checkbox.
The file is looking better but some columns are being displayed as strings when they are clearly numerical data. We can fix this by selecting "numeric" from the column dropdown.

The final step is to click "Import" to run the code under "Code Preview" and import the data into RStudio, the final result should look as follows:

Importing data from SPSS, SAS and Stata files
The SPSS, SAS and Stata importer provides support to:
- Import from the file system or a url
- Rename the data set
- Specify a model file
We can import https://github.com/rstudio/webinars/raw/master/23-Importing-Data-into-R/data/Child_Data.sav by pasting the address under File/Url and clicking "Update" followed by clicking "Import".

Need Help?
RStudio Pro customers may open a discussion with RStudio Support at any time.
You may also ask for help from R and RStudio users on community.rstudio.com. Be sure to include a reproducible example of your issue. Click here to start a new community discussion.