read_sheet: Read/Write sheets (automatically detect the file type and...

Description Usage Arguments Details Examples

View source: R/read-sheet.R

Description

Read/Write sheets (automatically detect the file type and work accordingly)

write_sheet requires version 0.3.1.

Usage

1
2
3
4
read_sheet(x, id_column, start_row = 1, sheet = 1, ext, header = TRUE,
  verbose = FALSE, ...)

write_sheet(x, file, ext, ...)

Arguments

x

read: path to a file, to be read. write: a data.frame

id_column

all rows which have this column as blank are skipped. See details.

start_row

supplied to read.xlsx

sheet

supplied to read.xlsx, index or name of the sheet to be read from excel file. See read.xlsx

ext

determined using file extention. Specifying will override

header

first line is header? See read.table

verbose

verbosity level.

...

passed onto read.xlsx of openxlsx, read.table or read.csv2 depending on the file type.

file

write: output file name.

Details

Note: for excel sheets:

Some important default values for tsv and csv files:

stringsAsFactors = FALSE,comment.char = '#', strip.white=TRUE, blank.lines.skip=TRUE

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## read a excel sheet
sheet = read_sheet(system.file("extdata/example.xlsx", package = "params"))

## read a comma seperated sheet
csv = read_sheet(system.file("extdata/example.csv", package = "params"))

## read a tab seperate sheet
tsv = read_sheet(system.file("extdata/example.tsv", package = "params"))


# write sheets -------

## write a comma seperated sheet
write_sheet(sheet, "example.csv")

## write a tab seperated sheet
write_sheet(sheet, "example.tsv")

## write an excel seperated sheet
write_sheet(sheet, "example.xlsx")

params documentation built on May 29, 2017, 12:25 p.m.