Last data update: 2014.03.03

R: Create a source object.
datasourceR Documentation

Create a source object.

Description

Create a source object.

Usage

datasource(file, skip = 0, comment = "")

Arguments

file

Either a path to a file, a connection, or literal data (either a single string or a raw vector).

Files ending in .gz, .bz2, .xz, or .zip will be automatically uncompressed. Files starting with http://, https://, ftp://, or ftps:// will be automatically downloaded. Remote gz files can also be automatically downloaded & decompressed.

Literal data is most useful for examples and tests. It must contain at least one new line to be recognised as data (instead of a path).

skip

Number of lines to skip before reading data.

Examples

# Literal csv
datasource("a,b,c\n1,2,3")
datasource(charToRaw("a,b,c\n1,2,3"))

# Strings
datasource(system.file("extdata/mtcars.csv", package = "readr"))
datasource(system.file("extdata/mtcars.csv.bz2", package = "readr"))
datasource(system.file("extdata/mtcars.csv.zip", package = "readr"))
datasource("https://github.com/hadley/readr/raw/master/inst/extdata/mtcars.csv")

# Connection
datasource(rawConnection(charToRaw("abc\n123")))

Results