File: data_separate.md

package info (click to toggle)
r-cran-datawizard 1.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,300 kB
  • sloc: sh: 13; makefile: 2
file content (154 lines) | stat: -rw-r--r-- 3,679 bytes parent folder | download
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# data_separate: multiple columns

    Code
      out
    Output
        x_1 x_2  x_3  y_1  y_2  y_3
      1   1   a    6    m    n   99
      2   2   b    7   77    f    g
      3   3   c    8   44    9 <NA>
      4   5   j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
        x_1 x_2  x_3  y_1  y_2  y_3
      1   1   a    6    m    n   99
      2   2   b  7 d   77    f    g
      3   3   c    8   44    9 <NA>
      4   5   j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
        x_A x_B  x_C  y_A  y_B  y_C
      1   1   a    6    m    n   99
      2   2   b  7 d   77    f    g
      3   3   c    8   44    9 <NA>
      4   5   j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
              x      y x_A x_B  x_C  y_A  y_B  y_C
      1   1.a.6 m.n.99   1   a    6    m    n   99
      2 2.b.7.d 77.f.g   2   b  7 d   77    f    g
      3   3.c.8   44.9   3   c    8   44    9 <NA>
      4     5.j   <NA>   5   j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
        x_1 x_2  x_3  y_1  y_2  y_3
      1   1   a    6    m    n   99
      2   b   7    d   77    f    g
      3   3   c    8   44    9 <NA>
      4   5   j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
              x      y x_A x_B x_C  y_A  y_B  y_C
      1   1.a.6 m.n.99   1   a   6    m    n   99
      2 2.b.7.d 77.f.g   2   b 7 d   77    f    g
      3   3.c.8   44.9   3   c   8   44    9    9
      4     5.j   <NA>   5   j   j <NA> <NA> <NA>

---

    Code
      out
    Output
              x      y   A   B   C
      1   1.a.6 m.n.99  1m  an 699
      2 2.b.7.d 77.f.g 277  bf 7dg
      3   3.c.8   44.9 344  c9  89
      4     5.j   <NA> 5NA jNA jNA

---

    Code
      out
    Output
              x      y   A   B    C
      1   1.a.6 m.n.99  1m  an  699
      2 2.b.7.d 77.f.g 277  bf   7g
      3   3.c.8   44.9 344  c9  8NA
      4     5.j   <NA> 5NA jNA NANA

---

    Code
      out
    Output
        x_1 x_2 x_3  y_1  y_2  y_3
      1   1   a   6    m    n   99
      2   2   b   7   77    f    g
      3   3   c   8   44   44    9
      4   5   5   j <NA> <NA> <NA>

# data_separate: multiple columns, different lengths

    Code
      out
    Output
        A B    C   EE   FF   GG
      1 1 a    6    m    n   99
      2 2 b    7   77    f    g
      3 3 c    8   44    9 <NA>
      4 5 j <NA> <NA> <NA> <NA>

---

    Code
      out
    Output
        A B    C   EE   FF   GG   HH
      1 1 a    6    m    n   99   22
      2 2 b    7   77    f    g   34
      3 3 c    8   44    9 <NA> <NA>
      4 5 j <NA> <NA> <NA> <NA> <NA>

# data_separate: fail if invalid column selected

    Code
      data_separate(d_sep, guess_columns = "mode", select = NULL)
    Message
      Column `x` had different number of values after splitting. Variable was
        split into 3 columns.
      `x` returned more columns than expected after splitting. Right-most
        columns have been dropped.
      `x`returned fewer columns than expected after splitting. Right-most
        columns were filled with `NA`.
      Column `y` had different number of values after splitting. Variable was
        split into 3 columns.
      `y`returned fewer columns than expected after splitting. Right-most
        columns were filled with `NA`.
    Output
        x_1 x_2  x_3  y_1  y_2  y_3
      1   1   a    6    m    n   99
      2   2   b    7   77    f    g
      3   3   c    8   44    9 <NA>
      4   5   j <NA> <NA> <NA> <NA>

# data_separate: numeric column

    Code
      out
    Output
              y x_1 x_2 x_3 x_4
      V1 m.n.99  15 435 352   3
      V2 77.f.g  53 554 353   2
      V3   44.9  12 342 422    
      V4   <NA>  15 454 334 535