import: Import a dataset

Description Usage Arguments Details Value See Also Examples

View source: R/import.R

Description

The import function can import data from delimited text files, Excel spreadsheets, and statistical packages such as SAS, SPSS, and Stata.

Usage

1
import(file, quietly = TRUE, ...)

Arguments

file

datafile to import. If missing, the user is prompted to select a file interactively.

quietly

logical. If quietly=FALSE, the data frame is described after import.

...

parameters passed to the import function. See details.

Details

The import function is a wrapper for the haven, readxl, and vroom packages. The vroom package provides one of the fastest methods for importing delimited text files currently available.

Files are imported based on their extension (.sas7bdat for SAS, .sav for SPSS, .dta for Stata, and .xls or .xlsx for Excel). All other file extensions are assumed to belong to delimited text files (e.g., comma or tab delimited files).

If you import a delimited text file without options, the structure and delimiters are determined from the first 100 rows.You can override these guesses by specifying options (e.g., sep=";", na="999").

Value

a data frame (tibble)

See Also

read_sas, read_dta, read_spss, read_excel, vroom

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 

 # import a comma delimited file
 mydataframe <- import("mydata.csv")

 # import a SAS binary datafile and describe the results
 mydataframe <- import("mydata.sas7bdat", quietly=FALSE)

 # import the second worksheet of an Excel workbook
 mydataframe <- import("mydata.xlsx", sheet=2)

 # prompt for a file to import
 mydataframe <- import()

## End(Not run)

Rkabacoff/qacr documentation built on March 20, 2021, 3:03 p.m.