Learn R Programming

rio (version 0.1.2)

import: Reading data frame or matrix from a file

Description

This function imports a data frame or matrix from a data file with the file format based on the file extension.

Usage

import(file = "", format = NULL, header = TRUE, ...)

Arguments

file
a character string naming a file.
format
a character string code of file format. The following file formats are supported: txt, rds, csv, dta, sav, mtp and rec.
header
a logical value indicating whether the file contains the names of the variables as its first line.
...
Additional arguments for the underlying import functions.

Examples

Run this code
#x <- import("iris.dta")
myIris <- datasets::iris
export(myIris, "myIris.csv", row.names=TRUE)
myIris2 <- import("myIris.csv") ### with the additional spurious column
head(myIris2)
myIris3 <- import("myIris.csv", row.names=1)
head(myIris3)

Run the code above in your browser using DataLab