Skip to content

Commit

Permalink
Update tidyr pivoting
Browse files Browse the repository at this point in the history
  • Loading branch information
aphalo committed Jul 27, 2023
1 parent 470ecdc commit 6fd8127
Show file tree
Hide file tree
Showing 29 changed files with 456,149 additions and 29,699 deletions.
69 changes: 44 additions & 25 deletions R.data.Rnw

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions R.data.containers.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,15 @@ head(my_data_frame.df, 2)
Use of \Rscoping{attach()} and \Rscoping{detach()}, which function as a pair of ON and OFF switches, can result in an undesired after-effect on name lookup if the script terminates after \Rscoping{attach()} is executed but before \Rscoping{detach()} is called, as cleanup is not automatic. In contrast, \Rscoping{with()} and \Rscoping{within()}, being self-contained, guarantee that cleanup takes place. Consequently, the usual recommendation is to give preference to the use of \Rscoping{with()} and \Rscoping{within()} over \Rscoping{attach()} and \Rscoping{detach()}. Use of these functions not only saves typing but also makes code more readable.
\end{explainbox}

\section{Reshaping data frames}\label{sec:calc:reshape}
\index{data frames!long vs.\ wide shape}

As mentioned above, in most cases in \Rlang data rows represent measurement events or observations possibly on multiple response variables and factors describing groupings, i.e., long shape. However, when measurements are repeated in time, columns rather frequently represent observations of the same response variable at different times, i.e., wide shape. Other cases exist where reshaping is needed. Function \Rfunction{reshape()} can convert wide data frames into long data frames and vice versa.

<<data-frames-reshape-01>>=
## reshape() example needed
@

\index{data frames|)}

<<data-frames-cleanup,echo=FALSE,cache=FALSE>>=
Expand Down
143 changes: 143 additions & 0 deletions R.data.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
% !Rnw root = appendix.main.Rnw














































































































































51 changes: 24 additions & 27 deletions appendixes.prj
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,55 @@
1
1
using-r-main-crc.Rnw
19
15
8
18
14
9

using-r-main-crc.Rnw
TeX:RNW:UTF-8
134217730 0 216 56 216 60 6074 -1 6458 208 1 1 974 1050 1 906 254 255 -1 0 0 33 1 0 60 216 0 -1 0
134217730 0 185 13 185 17 6074 -1 6458 208 1 1 321 230 1 906 254 255 -1 0 0 33 1 0 17 185 0 -1 0
preface.Rnw
TeX:RNW
1060859 0 -1 5790 -1 7346 266 266 1252 1324 1 1 1674 600 -1 -1 0 0 18 -1 -1 18 1 0 7346 -1 0 -1 0
1060859 0 -1 5790 -1 7346 266 266 1252 1324 1 1 321 598 -1 -1 0 0 18 -1 -1 18 1 0 7346 -1 0 -1 0
R.learning.Rnw
TeX:RNW
17838075 0 -1 22561 -1 22561 304 304 1290 1362 1 1 638 550 -1 -1 0 0 40 -1 -1 40 1 0 22561 -1 0 -1 0
17838075 0 -1 22561 -1 22561 304 304 1290 1362 1 1 549 553 -1 -1 0 0 40 -1 -1 40 1 0 22561 -1 0 -1 0
R.as.calculator.Rnw
TeX:RNW
17838075 0 -1 98905 -1 0 190 190 1324 1242 1 1 148 0 -1 -1 0 0 31 -1 -1 31 3 0 0 -1 1 70542 -1 2 11719 -1 0 -1 0
17838075 0 -1 98905 -1 0 190 190 1324 1242 1 1 129 0 -1 -1 0 0 31 -1 -1 31 3 0 0 -1 1 70542 -1 2 11719 -1 0 -1 0
R.data.containers.Rnw
TeX:RNW
17838075 0 -1 45280 -1 45292 190 190 1324 1242 1 1 821 600 -1 -1 0 0 31 -1 -1 31 3 0 45292 -1 1 192 -1 2 192 -1 0 -1 0
17838075 0 -1 54162 -1 54178 190 190 1324 1242 1 1 453 483 -1 -1 0 0 31 -1 -1 31 3 0 54178 -1 1 192 -1 2 192 -1 0 -1 0
R.functions.Rnw
TeX:RNW
17838075 0 -1 31095 -1 94 456 456 1442 1484 1 1 555 25 -1 -1 0 0 31 -1 -1 31 1 0 94 -1 0 -1 0
17838075 0 -1 31095 -1 94 456 456 1442 1484 1 1 477 23 -1 -1 0 0 31 -1 -1 31 1 0 94 -1 0 -1 0
R.scripts.Rnw
TeX:RNW
17838075 0 -1 30341 -1 30388 152 152 1138 1210 1 1 512 675 -1 -1 0 0 31 -1 -1 31 2 0 30388 -1 1 57458 -1 0 -1 0
17838075 0 -1 30341 -1 30388 152 152 1138 1210 1 1 1221 621 -1 -1 0 0 31 -1 -1 31 2 0 30388 -1 1 57458 -1 0 -1 0
R.stats.rnw
TeX:RNW
17838075 0 -1 16353 -1 16094 418 418 1404 1476 1 1 1702 175 -1 -1 0 0 31 -1 -1 31 1 0 16094 -1 0 -1 0
17838075 0 -1 16353 -1 16094 418 418 1404 1476 1 1 1461 161 -1 -1 0 0 31 -1 -1 31 1 0 16094 -1 0 -1 0
R.plotting.Rnw
TeX:RNW
17838075 0 -1 225 -1 226 380 380 1366 1438 1 1 549 161 -1 -1 0 0 31 -1 -1 31 1 0 226 -1 0 -1 0
R.data.Rnw
TeX:RNW
269496315 0 648 31 -1 38807 342 342 1328 1400 1 1 414 1100 -1 -1 0 0 31 -1 -1 31 1 0 38807 -1 0 -1 0
using-r-main-crc.tex
TeX
1060859 7 -1 56719 -1 56701 130 130 919 707 1 1 148 1025 -1 -1 0 0 49 -1 -1 49 1 0 56701 -1 0 -1 0
269496315 0 -1 39079 -1 40489 342 342 1328 1400 1 1 129 230 -1 -1 0 0 31 -1 -1 31 1 0 40489 -1 0 -1 0
references.bib
BibTeX
1049586 2 436 21 436 25 76 76 1467 997 1 1 417 575 -1 -1 0 0 23 0 0 23 1 0 25 436 0 -1 0
R.data.io.Rnw
TeX:RNW
17838075 1 -1 13190 -1 13203 494 494 1480 1522 1 1 817 400 -1 -1 0 0 31 -1 -1 31 1 0 13203 -1 0 -1 0
R.plotting.Rnw
TeX:RNW
17838075 0 -1 225 -1 226 380 380 1366 1438 1 1 672 175 -1 -1 0 0 31 -1 -1 31 1 0 226 -1 0 -1 0
17838075 1 -1 13190 -1 13203 494 494 1480 1522 1 1 681 506 -1 -1 0 0 31 -1 -1 31 1 0 13203 -1 0 -1 0
rbooks.bib
BibTeX
1049586 0 785 7 782 2 38 38 1429 959 1 1 162 600 -1 -1 0 0 21 0 0 21 1 0 2 782 0 -1 0
references.bib
BibTeX
1049586 2 436 21 436 25 76 76 1467 997 1 1 484 575 -1 -1 0 0 23 0 0 23 1 0 25 436 0 -1 0
1049586 2 667 7 667 15 38 38 1429 959 1 1 297 322 -1 -1 0 0 21 0 0 21 1 0 15 667 0 -1 0
usingr.sty
TeX:STY
1060850 1 59 13 59 23 190 190 1176 1248 1 0 437 -275 -1 -1 0 0 25 0 0 25 1 0 23 59 0 0 0
using-r-main-crc.idx
TeX:AUX:UNIX
269594610 1 0 1 0 62 266 266 1657 1157 1 0 844 0 -1 -1 0 0 51 0 0 51 1 0 62 0 0 0 0
1060850 1 59 13 59 23 190 190 1176 1248 1 0 376 598 -1 -1 0 0 25 0 0 25 1 0 23 59 0 0 0
using-r-main-crc.tex
TeX
269496315 8 -1 834129 -1 833774 130 130 919 707 1 1 465 299 -1 -1 0 0 49 -1 -1 49 1 0 833774 -1 0 -1 0
R.intro.Rnw
TeX:RNW
17838075 0 -1 36426 -1 36429 228 228 1214 1286 1 1 1233 322 -1 -1 0 0 30 -1 -1 30 1 0 36429 -1 0 -1 0
Expand Down
51 changes: 24 additions & 27 deletions appendixes.prj.bak
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,55 @@
1
1
using-r-main-crc.Rnw
19
15
8
18
14
0

using-r-main-crc.Rnw
TeX:RNW:UTF-8
134217730 0 216 56 216 60 6074 -1 6458 208 1 1 974 1050 1 906 254 255 -1 0 0 33 1 0 60 216 0 -1 0
402653186 0 185 13 185 17 6074 -1 6458 208 1 1 321 230 1 906 254 255 -1 0 0 33 1 0 17 185 0 -1 0
preface.Rnw
TeX:RNW
1060859 0 -1 5790 -1 7346 266 266 1252 1324 1 1 1674 600 -1 -1 0 0 18 -1 -1 18 1 0 7346 -1 0 -1 0
1060859 0 -1 5790 -1 7346 266 266 1252 1324 1 1 321 598 -1 -1 0 0 18 -1 -1 18 1 0 7346 -1 0 -1 0
R.learning.Rnw
TeX:RNW
17838075 0 -1 22561 -1 22561 304 304 1290 1362 1 1 638 550 -1 -1 0 0 40 -1 -1 40 1 0 22561 -1 0 -1 0
17838075 0 -1 22561 -1 22561 304 304 1290 1362 1 1 549 553 -1 -1 0 0 40 -1 -1 40 1 0 22561 -1 0 -1 0
R.as.calculator.Rnw
TeX:RNW
17838075 0 -1 98905 -1 0 190 190 1324 1242 1 1 148 0 -1 -1 0 0 31 -1 -1 31 3 0 0 -1 1 70542 -1 2 11719 -1 0 -1 0
17838075 0 -1 98905 -1 0 190 190 1324 1242 1 1 129 0 -1 -1 0 0 31 -1 -1 31 3 0 0 -1 1 70542 -1 2 11719 -1 0 -1 0
R.data.containers.Rnw
TeX:RNW
17838075 0 -1 45280 -1 45292 190 190 1324 1242 1 1 821 600 -1 -1 0 0 31 -1 -1 31 3 0 45292 -1 1 192 -1 2 192 -1 0 -1 0
17838075 0 -1 54162 -1 54178 190 190 1324 1242 1 1 453 483 -1 -1 0 0 31 -1 -1 31 3 0 54178 -1 1 192 -1 2 192 -1 0 -1 0
R.functions.Rnw
TeX:RNW
17838075 0 -1 31095 -1 94 456 456 1442 1484 1 1 555 25 -1 -1 0 0 31 -1 -1 31 1 0 94 -1 0 -1 0
17838075 0 -1 31095 -1 94 456 456 1442 1484 1 1 477 23 -1 -1 0 0 31 -1 -1 31 1 0 94 -1 0 -1 0
R.scripts.Rnw
TeX:RNW
17838075 0 -1 30341 -1 30388 152 152 1138 1210 1 1 512 675 -1 -1 0 0 31 -1 -1 31 2 0 30388 -1 1 57458 -1 0 -1 0
17838075 0 -1 30341 -1 30388 152 152 1138 1210 1 1 1221 621 -1 -1 0 0 31 -1 -1 31 2 0 30388 -1 1 57458 -1 0 -1 0
R.stats.rnw
TeX:RNW
17838075 0 -1 16353 -1 16094 418 418 1404 1476 1 1 1702 175 -1 -1 0 0 31 -1 -1 31 1 0 16094 -1 0 -1 0
17838075 0 -1 16353 -1 16094 418 418 1404 1476 1 1 1461 161 -1 -1 0 0 31 -1 -1 31 1 0 16094 -1 0 -1 0
R.plotting.Rnw
TeX:RNW
17838075 0 -1 225 -1 226 380 380 1366 1438 1 1 549 161 -1 -1 0 0 31 -1 -1 31 1 0 226 -1 0 -1 0
R.data.Rnw
TeX:RNW
269496315 0 648 31 -1 38807 342 342 1328 1400 1 1 414 1100 -1 -1 0 0 31 -1 -1 31 1 0 38807 -1 0 -1 0
using-r-main-crc.tex
TeX
1060859 7 -1 56719 -1 56701 130 130 919 707 1 1 148 1025 -1 -1 0 0 49 -1 -1 49 1 0 56701 -1 0 -1 0
1060859 1 -1 39182 -1 39175 342 342 1328 1400 1 1 513 529 -1 -1 0 0 31 -1 -1 31 1 0 39175 -1 0 -1 0
references.bib
BibTeX
1049586 2 436 21 436 25 76 76 1467 997 1 1 417 575 -1 -1 0 0 23 0 0 23 1 0 25 436 0 -1 0
R.data.io.Rnw
TeX:RNW
17838075 1 -1 13190 -1 13203 494 494 1480 1522 1 1 817 400 -1 -1 0 0 31 -1 -1 31 1 0 13203 -1 0 -1 0
R.plotting.Rnw
TeX:RNW
17838075 0 -1 225 -1 226 380 380 1366 1438 1 1 672 175 -1 -1 0 0 31 -1 -1 31 1 0 226 -1 0 -1 0
17838075 1 -1 13190 -1 13203 494 494 1480 1522 1 1 681 506 -1 -1 0 0 31 -1 -1 31 1 0 13203 -1 0 -1 0
rbooks.bib
BibTeX
1049586 0 785 7 782 2 38 38 1429 959 1 1 162 600 -1 -1 0 0 21 0 0 21 1 0 2 782 0 -1 0
references.bib
BibTeX
1049586 2 436 21 436 25 76 76 1467 997 1 1 484 575 -1 -1 0 0 23 0 0 23 1 0 25 436 0 -1 0
1049586 2 667 7 667 15 38 38 1429 959 1 1 297 322 -1 -1 0 0 21 0 0 21 1 0 15 667 0 -1 0
usingr.sty
TeX:STY
1060850 1 59 13 59 23 190 190 1176 1248 1 0 437 -275 -1 -1 0 0 25 0 0 25 1 0 23 59 0 0 0
using-r-main-crc.idx
TeX:AUX:UNIX
269594610 1 0 1 0 62 266 266 1657 1157 1 0 844 0 -1 -1 0 0 51 0 0 51 1 0 62 0 0 0 0
1060850 1 59 13 59 23 190 190 1176 1248 1 0 376 598 -1 -1 0 0 25 0 0 25 1 0 23 59 0 0 0
using-r-main-crc.tex
TeX
269496315 0 -1 5058 -1 5058 130 130 919 707 1 1 909 299 -1 -1 0 0 49 -1 -1 49 1 0 5058 -1 0 -1 0
R.intro.Rnw
TeX:RNW
17838075 0 -1 36426 -1 36429 228 228 1214 1286 1 1 1233 322 -1 -1 0 0 30 -1 -1 30 1 0 36429 -1 0 -1 0
Expand Down
Loading

0 comments on commit 6fd8127

Please sign in to comment.