fread_fragmented: Read fragmented table from a flat file (DOES NOT WORK).

Description Usage Arguments Value Examples

View source: R/fread_fragmented.R

Description

A convenience function, that wraps fread from package data.table.

Usage

1
fread_fragmented(x, stringsAsFactors = TRUE, ...)

Arguments

x

(character) Either a path to a file, a connection, or literal data (either a single string or a raw vector).
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).

Value

A data frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Not run: \donttest{

# Contents of file "data-raw/CO_head.txt":

#   Plant   Type  Treatment
# 1   Qn1 Quebec nonchilled
# 2   Qn1 Quebec nonchilled
# 3   Qn1 Quebec nonchilled
#   conc uptake
# 1   95   16.0
# 2  175   30.4
# 3  250   34.8


fread_fragmented("data-raw/CO_head.txt")

##   Plant   Type  Treatment conc uptake
## 1   Qn1 Quebec nonchilled   95   16.0
## 2   Qn1 Quebec nonchilled  175   30.4
## 3   Qn1 Quebec nonchilled  250   34.8
##
## Warning messages:
##     1: Missing column names filled in: 'X1' [1]
##     2: Missing column names filled in: 'X1' [1]

# These warning messages are expected.

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rez <- read_fragmented_table(
"   Plant   Type  Treatment
1   Qn1 Quebec nonchilled
2   Qn1 Quebec nonchilled
3   Qn1 Quebec nonchilled
  conc uptake
1   95   16.0
2  175   30.4
3  250   34.8")

rez
#   Plant   Type  Treatment conc uptake
# 1   Qn1 Quebec nonchilled   95   16.0
# 2   Qn1 Quebec nonchilled  175   30.4
# 3   Qn1 Quebec nonchilled  250   34.8
}
## End(Not run)

GegznaV/conspect.helper documentation built on July 28, 2017, 9:26 a.m.