read.df: Read a csv file

Description Usage Arguments Value Examples

View source: R/io.R

Description

Read a csv file

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
read.df(
  file.path,
  sep = ";",
  max.n.factor = 3,
  header = FALSE,
  row.names = NULL,
  col.names = NULL,
  n.rows = -1L,
  transpose = FALSE
)

Arguments

file.path

Name of input file

sep

Field separator. Default ;

max.n.factor

maximum number of column characters to be a factor. Default 3.

header

a logical value indicating whether the file contains the names of the variables as its first line. Default FALSE.

row.names

a vector of row names. Default NULL.

col.names

a vector of col names. Default NULL.

n.rows

integer: the maximum number of rows to read in. In case of Header = TRUE, it does not count for the number of read lines.

transpose

If TRUE, transpose the result. Default FALSE.

Value

A data frame containing a representation of the data in the file.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df = data.frame("V1" = 1:5, "V2" = c("a", "b", "c", "d", "e"), "V3" = c("alto", "bajo", "bajo", "alto", "alto"))
write.df(df, "bench1.txt")
read.df(file.path = "bench1.txt")

write.df(df, "bench2.txt", header = TRUE)
read.df(file.path = "bench2.txt", header = TRUE)

write.df(df, "bench2.txt", append = TRUE)
read.df(file.path = "bench2.txt", header = FALSE)

write.df(df, "bench2.txt", sep = ";", header = FALSE, append = TRUE)
read.df(file.path = "bench2.txt", sep = ";", header = TRUE,  max.n.factor = 3, row.names = c('X1', 'X2', 'X3', 'X4', 'X5'), col.names = c('A', 'B', 'C'), n.rows = 5, transpose = FALSE)

AnderEhu/sme documentation built on Jan. 31, 2022, 12:01 a.m.