simple_table: Read a simple table

Description Usage Arguments Value Examples

View source: R/simple_table.R

Description

Read tables given in more or less elaborate human-readable formats

Usage

1
2
simple_table(x, header = TRUE, rem.dup.header = header,
  na.strings = c("NA", "N/A"), stringsAsFactors = FALSE, ...)

Arguments

x

a teble represented as a character string

header

are the table columns named? By default TRUE

rem.dup.header

remove duplicated headers.

na.strings

a character vector of strings which are to be interpreted as NA values

stringsAsFactors

should character vectors be converted to factors? By default FALSE

...

further arguments passed to read.table

Value

A data.frame containing a representation of the data.

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
x1 <- "
+------------+------+------+----------+--------------------------+
|    Date    | Emp1 | Case | Priority | PriorityCountinLast7days |
+------------+------+------+----------+--------------------------+
| 2018-06-01 | A    | A1   |        0 |                        0 |
| 2018-06-03 | A    | A2   |        0 |                        1 |
| 2018-06-02 | B    | B2   |        0 |                        2 |
| 2018-06-03 | B    | B3   |        0 |                        3 |
+------------+------+------+----------+--------------------------+
"

x2 <- "
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
    Date    | Emp1 | Case | Priority | PriorityCountinLast7days 
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 2018-06-01 | A    | A|1  |        0 |                        0 
 2018-06-03 | A    | A|2  |        0 |                        1 
 2018-06-02 | B    | B|2  |        0 |                        2 
 2018-06-03 | B    | B|3  |        0 |                        3 
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
"

x3 <- "
 Maths | English | Science | History | Class

  0.1  |  0.2    |  0.3    |  0.2    |  Y2

  0.9  |  0.5    |  0.7    |  0.4    |  Y1

  0.2  |  0.4    |  0.6    |  0.2    |  Y2

  0.9  |  0.5    |  0.2    |  0.7    |  Y1
"

x4 <- "
         Season |   Team  | W | AHWO
-------------------------------------
1  |  2017/2018 |  TeamA  | 2 | 1.75
2  |  2017/2018 |  TeamB  | 1 | 1.85
3  |  2017/2018 |  TeamC  | 1 | 1.70
4  |  2017/2018 |  TeamD  | 0 | 3.10
5  |  2016/2017 |  TeamA  | 1 | 1.49
6  |  2016/2017 |  TeamB  | 3 | 1.51
7  |  2016/2017 |  TeamC  | 2 | 1.90
8  |  2016/2017 |  TeamD  | 0 | N/A 
"

x5 <- "
    A   T   G   C
   ---------------
A | 6 | 0 | 4 | 0 |
  |---:---:---:---
T | 0 | 6 | 0 | 4 |
  |---:---:---:---
G | 4 | 0 | 6 | 0 |
  |---:---:---:---
C | 0 | 4 | 0 | 6 |
   ---------------
"

x6 <- "
------------------------------------------------------------
|date              |Material          |Description         |
|----------------------------------------------------------|
|10/04/2013        |WM.5597394        |PNEUMATIC           |
|11/07/2013        |GB.D040790        |RING                |
------------------------------------------------------------

------------------------------------------------------------
|date              |Material          |Description         |
|----------------------------------------------------------|
|08/06/2013        |WM.4M01004A05     |TOUCHEUR            |
|08/06/2013        |WM.4M010108-1     |LEVER               |
------------------------------------------------------------
"

lapply(c(x1, x2, x3, x4, x5, x6), simple_table)

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.