-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.tex
2794 lines (2169 loc) · 87.6 KB
/
index.tex
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
letterpaper,
DIV=11,
numbers=noendperiod]{scrreprt}
\usepackage{amsmath,amssymb}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
\usepackage{xcolor}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\setcounter{secnumdepth}{5}
% Make \paragraph and \subparagraph free-standing
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother
% Scale images if necessary, so that they will not overflow the page
% margins by default, and it is still possible to overwrite the defaults
% using explicit options in \includegraphics[width, height, ...]{}
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
% Set default figure placement to htbp
\makeatletter
\def\fps@figure{htbp}
\makeatother
\usepackage{booktabs}
\usepackage{caption}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage{array}
\KOMAoption{captions}{tableheading}
\makeatletter
\@ifpackageloaded{tcolorbox}{}{\usepackage[skins,breakable]{tcolorbox}}
\@ifpackageloaded{fontawesome5}{}{\usepackage{fontawesome5}}
\definecolor{quarto-callout-color}{HTML}{909090}
\definecolor{quarto-callout-note-color}{HTML}{0758E5}
\definecolor{quarto-callout-important-color}{HTML}{CC1914}
\definecolor{quarto-callout-warning-color}{HTML}{EB9113}
\definecolor{quarto-callout-tip-color}{HTML}{00A047}
\definecolor{quarto-callout-caution-color}{HTML}{FC5300}
\definecolor{quarto-callout-color-frame}{HTML}{acacac}
\definecolor{quarto-callout-note-color-frame}{HTML}{4582ec}
\definecolor{quarto-callout-important-color-frame}{HTML}{d9534f}
\definecolor{quarto-callout-warning-color-frame}{HTML}{f0ad4e}
\definecolor{quarto-callout-tip-color-frame}{HTML}{02b875}
\definecolor{quarto-callout-caution-color-frame}{HTML}{fd7e14}
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same} % disable monospaced font for URLs
\hypersetup{
pdftitle={Excel to R: A Survivor's Guide for the Corporate Environment},
pdfauthor={Alejandro Hagan},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{Excel to R: A Survivor's Guide for the Corporate Environment}
\author{Alejandro Hagan}
\date{2003-09-10}
\begin{document}
\maketitle
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{2}
\tableofcontents
}
\chapter*{Index}\label{index}
\addcontentsline{toc}{chapter}{Index}
\markboth{Index}{Index}
\section*{Excel to R: A Survivor's Guide for the Corporate
Environment}\label{excel-to-r-a-survivors-guide-for-the-corporate-environment}
\addcontentsline{toc}{section}{Excel to R: A Survivor's Guide for the
Corporate Environment}
\markright{Excel to R: A Survivor's Guide for the Corporate Environment}
\section*{Introduction}\label{introduction}
\addcontentsline{toc}{section}{Introduction}
\markright{Introduction}
\section*{Set Up \& Configuration}\label{set-up-configuration}
\addcontentsline{toc}{section}{Set Up \& Configuration}
\markright{Set Up \& Configuration}
\begin{itemize}
\tightlist
\item
Rstudio
\item
Visual Studio
\item
Vim
\end{itemize}
\section*{The Whole Game}\label{the-whole-game}
\addcontentsline{toc}{section}{The Whole Game}
\markright{The Whole Game}
\begin{itemize}
\tightlist
\item
Reproducible research
\item
Version Control
\item
Importing data from different systems and environments
\item
Using statistical to shortcut business intelligence functions
\end{itemize}
\section*{Rethinking data}\label{rethinking-data}
\addcontentsline{toc}{section}{Rethinking data}
\markright{Rethinking data}
\begin{itemize}
\item
Learning about tabular data vs.~report data and why it is important
\item
Column naming convention and best practices
\item
data dictionary
\item
Data principles
\begin{verbatim}
-https://www.ibcs.com/
\end{verbatim}
\end{itemize}
\section*{lookup tables}\label{lookup-tables}
\addcontentsline{toc}{section}{lookup tables}
\markright{lookup tables}
\begin{itemize}
\tightlist
\item
how to create them
\item
how to use them
\end{itemize}
\section*{Augmenting and creating
calculation}\label{augmenting-and-creating-calculation}
\addcontentsline{toc}{section}{Augmenting and creating calculation}
\markright{Augmenting and creating calculation}
\begin{itemize}
\tightlist
\item
adding columns and calculated columns
\end{itemize}
\section*{\#\# grouping and summzaring (super power
1)}\label{grouping-and-summzaring-super-power-1}
\addcontentsline{toc}{section}{\#\# grouping and summzaring (super power
1)}
\markright{\#\# grouping and summzaring (super power 1)}
\section*{\#\# filter, duplicates, advanced
aggregations}\label{filter-duplicates-advanced-aggregations}
\addcontentsline{toc}{section}{\#\# filter, duplicates, advanced
aggregations}
\markright{\#\# filter, duplicates, advanced aggregations}
\section*{Time Intelligence
Functions}\label{time-intelligence-functions}
\addcontentsline{toc}{section}{Time Intelligence Functions}
\markright{Time Intelligence Functions}
\begin{itemize}
\tightlist
\item
Power BI type intelligence functions
\end{itemize}
\section*{Merge and joins (super power
2)}\label{merge-and-joins-super-power-2}
\addcontentsline{toc}{section}{Merge and joins (super power 2)}
\markright{Merge and joins (super power 2)}
\section*{pivot and unpivot (super power
3)}\label{pivot-and-unpivot-super-power-3}
\addcontentsline{toc}{section}{pivot and unpivot (super power 3)}
\markright{pivot and unpivot (super power 3)}
\section*{columnwise vs.~rowwise aggregation (super power
4)}\label{columnwise-vs.-rowwise-aggregation-super-power-4}
\addcontentsline{toc}{section}{columnwise vs.~rowwise aggregation (super
power 4)}
\markright{columnwise vs.~rowwise aggregation (super power 4)}
\section*{Importing Data}\label{importing-data}
\addcontentsline{toc}{section}{Importing Data}
\markright{Importing Data}
\section*{Spark \& Database}\label{spark-database}
\addcontentsline{toc}{section}{Spark \& Database}
\markright{Spark \& Database}
\section*{Statistical Applications for Buinsess
Intelligence}\label{statistical-applications-for-buinsess-intelligence}
\addcontentsline{toc}{section}{Statistical Applications for Buinsess
Intelligence}
\markright{Statistical Applications for Buinsess Intelligence}
\begin{itemize}
\tightlist
\item
lm+ simple= group\_by()+ summarize(mean)
\item
rq+ simple =group\_by()+summarize(median)
\item
lm+ interaction
\end{itemize}
\section*{Visualization packages}\label{visualization-packages}
\addcontentsline{toc}{section}{Visualization packages}
\markright{Visualization packages}
\begin{verbatim}
- ggplot()
-ggiraph
-gganimate
- gt()
- observablejs
\end{verbatim}
\begin{verbatim}
-- Attaching core tidyverse packages ------------------------ tidyverse 2.0.0 --
v dplyr 1.1.4 v readr 2.1.4
v forcats 1.0.0 v stringr 1.5.1
v ggplot2 3.5.0 v tibble 3.2.1
v lubridate 1.9.3 v tidyr 1.3.0
v purrr 1.0.2
-- Conflicts ------------------------------------------ tidyverse_conflicts() --
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
i Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
\end{verbatim}
\begin{verbatim}
Warning: Since gt v0.6.0 the `fmt_missing()` function is deprecated and will soon be
removed.
* Use the `sub_missing()` function instead.
This warning is displayed once every 8 hours.
\end{verbatim}
\begin{figure}
\centering{
\captionsetup{labelsep=none}
\begin{longtable*}{lllll}
\toprule
chapter & concept & excel & r & comment \\
\midrule\addlinespace[2.5pt]
& IDE & Ribbon vs. main vs. power pivot vs. power query
Customize ribbon
& Rmarkdown
Code chunks vs. text
kniting & \\
1 & Named objects; how to create objects, label and reference, and add columns or rows to the object
How to create series from existing functions including, numbers, dates and repeating strings
& - & - & Emphasis on tabular data
The need for quality data \\
1 & - & generating data & Generating data
-numbers
-letters
-dates
-rep()
-seq()
-mutate & - \\
1 & - & Named Cells & vectors,lists & - \\
1 & - & Named Tables & tibbles & - \\
1 & - & Adding Columns to Table & mutate & - \\
1 & - & Adding rows to Table & update\_rows? & - \\
1 & - & Referencing Named Objects & name & - \\
1 & - & Repeat last actions & ?? & - \\
1 & - & Tab References & & - \\
1 & - & edit named objects & ?? & - \\
1 & - & creating vectors & vectors & - \\
1 & - & fill series tips & tidyr::fill & - \\
1 & - & existing data & ?? & - \\
1 & - & create new series of numbers & seq() & - \\
1 & - & create new series of dates & seq.Date() & - \\
1 & - & creates new series of characters & sample() & - \\
1 & - & flash fill tips & ?? & - \\
1 & - & adding/subtracting/dividing/ multiplying columns & mutate & - \\
1 & - & one formula works against all rows in a column & group\_by()? & - \\
1 & - & rowwise equivalent & rowwise() & - \\
1 & - & colwise equivalent & colwise()? & - \\
1 & - & mean & mean & - \\
1 & - & median & median & - \\
1 & - & sum & sum & - \\
1 & - & count & n & - \\
1 & - & aggregate & match.args() & - \\
1 & - & error handling & - & - \\
1 & - & Iferror() & - & - \\
1 & - & NA vs. NULL vs. ref & - & - \\
1 & - & array & - & - \\
& Visualization Exercise 1 & Basic Table
Minimalist formatting
Borders
Alternatives to tables
Visualize/ emphasize word
Conditional formatting of values
Picking existing themes/ pallets
Picking custom colors
Bold / italics
Column format width / wrap
Perhaps practice making executive slides
Teaching how to present information in effective ways
sort & Gt() & \\
& Reading data & Have ten excel files, how do I read this information
In truth - with base excel no good ways only terrible ways
Can copy \&paste but that is manual and can be full of errors (columns out of line, paste over rows,etc) and limited to 1M rows
Typically people build a summarization report and then link to various reports that will update each month
Linked excel sheets (I will show you only because I know this is a reality but strongly recommend against this)
Strongly suggest to use power query and the below pattern & Readr
Readxl
rio & \\
& & & & \\
& Column types / data types & Why format columns are important
More than just visual, it enables calculations
Format Numeric, dates, strings, factor equivalent (weekdays)
& Forecat package
Fct\_lump
Fct\_reorder
Fct\_other
Fct\_relevel
Fct\_recode
Cut
& Excel gives a lot of flexibility which might seem like a great thing (eg. You don't get show stopping errors) but it is dangerous. If you have data entry errors or bad data(which, I promise, you do) you will miss extractions (eg summing up text)
Example of summing texts
Because of this most people don't pay particular attention to the text type, they usually associate type with formatting which is related but not the same
Again this saves you time as you can just enter any old thing and it "works" however whatever time you saved in this,I promise you loose in larger datesets when you have errors or performance issues
This is why we need to learn about data types and why coding languags are so particular about data types - many will just not allow you to proceed further until you establish this. This is usually a barrier and source of frustration for those learning
Exception is factors where the concept sort of exists in excel, try sorting the table and imagine you want to sort it by a custom order (not alphabetical)
Here you can create your own levels by using the list function, this enables a custom sort
Here is where you will already start to see some performance differences between excel in R when dealing with factors \\
& Visualization Exercise 2 & Bar chart
Dynamic reference
Stacked
Fill
Dodge
Line chart
X,y chart
Preset themes
customization & Geom\_col()
Geom\_line()
Aes()
Color()
Fill()
Shape()
Linetype()
Label\_wrap
Position()
Theme\_sets()
Theme()
Xlabs, ylabs, title, subtitle, caption
& \\
& Reinforce learning & & Factors
Rbloggers entry on factors
Skills validationL
Exercise x,y,z in different books & \\
& Sort, filter, remove duplicates, relevel & Number filter
text filters
Other filters: Color filters
Cell filter
Conditional filter
Sort \& relevel
Dates
Numbers
Text
A-z
custom lists
Field slicer
Timeline slicer
Match()
Find()
& Select
Filter & \\
& & & & \\
& More advanced aggregations running totals,
Ranks,
& Now we start with dealing with grouping or categorization of our data by attributes that aren't just in labels
This typically becomes necessary as we want to establish trends and insights into these group, some basic yet popular patterns are below
Bigger issues when dealing with data is understanding changes, most analysis concepts, are centered around a establish a center point and understanding each points distance from that point
Sometimes this is called variance analysis which can be within a group or how something has change dover time or an outlier
Here are some useful techniques or formulas to help categorize disperse data
Z score/ standardize
Log()
Running totals
Percent of total
ABC analysis
\%percentile
cohort
rank & & \\
& Group\_by / summarize functions/conditional aggregations/advanced references
Basic build out map
Group\_by vs. rowwise
Across/if\_any/if\_all
Rowwise
Where
Current\_group
& Index()
If()
\_ifs()
Pivot tables
Pivottablereferences
&
Ifelse
case\_when
\_join
Group\_by
Summarize
Rowwise
Columnwise
Count
Base R techniques too
Subset dataframes sum(df\$col==x)
& \\
& Error / NAs / NULLs & Iferror() & Is.na() & \\
& & & & \\
& & & & \\
& Time intelligence functions & Dates
One of the most frustating aspects of excel is that it turns your dates into numbers or xxxx
Data formula & Dates in general are a confusing concept even though we want it to be straight fowr & Dates in general are confusing concept even though we want it to be straight forward. Why because they are irregular and arbitrary. Different months have different days, different years have different days, and each year has parial days in it. We have time zones. So that opening is a bit of primer that working with dats in general can be frustrating no mater what tool or package you want to use \\
& Month over month & Group\_by
Summarize
Lead\_lag & Group\_by
Summarize
Lead / lag & \\
& Year over year & … & & \\
& Week over week & … & & \\
& Non\_standard\_calendar & Have no idea how to do this, like most things can be done, just a done of work - easier to use R
& Create calendar
Map weeks to normal weeks
Group\_by
Use lead/lag & \\
& Cummin,cummax,cummean & & & \\
& Rolling averages & & & \\
& Month to date & & & \\
& Year to date , & & & \\
& Quarter to date & & & \\
& Rates for days vs. aboslute amounts & & & \\
& Filter dates & & & \\
& & & & \\
& Merging / joining /conditional referencing & \_ifs()
Vlookup
Hlookup
Index(match)
Array formulas & Filter, groupby,summarize?
Left\_join
Full\_join
Rightjoin
Anti\_join & \\
& Categorizing / grouping techniques & Match()
Find()
Length()
Right()
Left()
Mid()
pivot table: group
Link to other excel models & Group\_by
Regex
str\_detect
Fct\_lump
Fct\_other
Relevel
recode & \\
& Visualizing data & Bar graphs & & \\
& Extract data & Power Query & & \\
& Transform data & Power Query & & \\
& Load data & Power Query & & \\
& Colors including custom colors & & Names(colors)<- factor\_names
Popular color packages
Discrete vs. continous
Manual assignment
Create your own!
& \\
& Factor analysis & & & \\
& Budge plan vs. plan, actuals for actuals
Allocations
Validation
Rates vs. absolute amounts & & & \\
& Tidy selection techniques
Selection based on names
Selection based on column criteria & & & \\
& Concatenate based on data outputs & & & \\
& Generate sample data
Index
Dates
Random figures
Random figures from a set or custom distribution
Simulations
& & & \\
& Contins()==match() & & & \\
& Enquo()==indirect() & & & \\
& Readr
Col\_spec
Cols() & & & \\
& map & & & \\
& OTHER & & & \\
& R in powerBi & & & \\
& R markdown & & & \\
ETL & csv & & & \\
& excel & & & \\
& SQL/snowflake & & & \\
& & & & \\
reporting & quarto & & & \\
& & & & \\
& & & & \\
& & & & \\
automation & Bash & & & \\
& & & & \\
& & & & \\
& & & & \\
& & & & \\
& & & & \\
& & & & \\
& - & - & - & - \\
\bottomrule
\end{longtable*}
}
\caption{\label{fig-toc}}
\end{figure}%
\part{Introduction}
\chapter*{Introduction}\label{introduction-2}
\addcontentsline{toc}{chapter}{Introduction}
\markboth{Introduction}{Introduction}
I have been to the darkest corners of the internet and beyond, searching
for answers to the most impossible data problems. I've scoured every
forum, every blog, every tutorial, and even ventured into the depths of
the forbidden knowledge that mere mortals should not possess. But fear
not, my friends, for I have returned with solutions that will save you
agony and frustration.
I'm not just talking about your everyday, run-of-the-mill data issues.
No, no, no. I'm talking about the kind of data that would make even the
most experienced analyst shake in their boots. Messy, inconsistent,
non-standard, and downright ugly data that makes you want to throw your
computer out the window. But fear not, for I have conquered these data
demons and emerged victorious.
And now, I am here to share my knowledge with you, my dear comrades in
data crunching. This book will solve 80\% of your data problems, with no
complex macros or advanced languages required. It's like a data
superhero that will swoop in and save the day, leaving you with more
time to sip on a margarita and bask in the glory of your newfound data
skills.
So if you're tired of staring at your computer screen, tears streaming
down your face, and feeling like you're stuck in a never-ending data
nightmare, then this book is for you. It's time to take back control of
your data, and with my help, you'll be a data champion in no time.
This is meant to quickly reference guide. I will teach you patterns
techniques so that you can quickly and effectively get to solutions to
your problems. This means building up your analysis frameworks and tool
kits.
If you've been counting, you've noticed I've used ``effective'' almost
15 times. What do I mean by that, I'm balancing your time, With all the
skills, you can (and some of you should) significantly advanced your
knowledge but what happens? For many of you, you'll build a tool only
you can use, you will need to spend significantly amount of your time
learning these skills and testing these skills. Things will go wrong.
You will be frustrated, eventually you'll get it right, you will be
better for it. But then you will move, the person replacing you will
have no clue what you are doing and will quickly undo it, and sure
you've learnt an advance skill, but unless your organization is build
around that level of skill standard - you may not intend it but you will
do more harm than good.
It also means you will be able to do a typical problem in an defined
amount of time. Trust me, there is no point reading this if you can't do
a simple analysis in 15 minutes. Why? Because you spent time training on
to have any benefit with your work.
By the time you are done, you will gladly look forward to data. It will
not intimidate you. You will be excited to quickly semi automate many of
your processes. You will be confident. You will be focus on value and
process.
I want to tell you that you will be able to great in 2 weeks but I will
lie to you. Yes, for sure you will do some great things very quickly and
if you are lucky enough that your data is already perfectly organized
and your management teams actually know what they want with data than
for sure - you will hit the ground running quickly. However for the rest
of us, it will take time to replicate your existing Excel skill set in R
and than surpass it. However, I promise you, this is investment is worth
it when you are able to automate a report in 10 minutes that used to
take you a week.
Be patient, the concepts taught here are not hard or complex they are
just \emph{different} than what you know. As you become more familiar
with the new concepts you will learn it very quickly.
\subsection*{Books purpose}\label{books-purpose}
\addcontentsline{toc}{subsection}{Books purpose}
This book will guide you through realistic business scenarios on how to
create and automate reports with an emphasis on maximizing your team's
effectiveness
You read this and 1) will know how to apply tools to the real life
situations that you have faced with an emphasis of effectiveness (as
defined by your team \& maintenance of the reports you build)
While there are some fantastic R reasources \url{www.bigbookofR.com},
the referenced example datasets rarely prepare you for the real life
complexities of dealing with Corporate datasets, including challenges of
dealing with messy Corporate datasets, maintaining reports when there is
significant process changes, and system and offline manual data
manipulation required to generate reports.
Additionally, whether it is R or python, most learning resources tend to
have a heavy focus on statistical techniques / applications which while
useful in certain contexts in reality do not help most analyst or
managers with their business reporting.
This book is focused on developing effective analyst skills that will
improve both your R and Excel skills, recognizing that he reality of
using exclusively being able to use R in a corporate environment is
rare. Furthermore by relating R to excel, you will gain a deeper
learning into how R works.
There will be better ways to do things that we are teaching you however,
they often involve wider resources or time commitments that you may not
be able to maintain (however we will provide resources in case you are
curious!)
\begin{quote}
The dirty secret of popular data science languages are they are
\textbf{perishable}, that is to say if you don't use them frequently you
will forget the techniques, syntax and common patterns to solve your
issues.
\end{quote}
the real barrier and challenge to learning R is not the language itself,
although you won't believe it now, R is very simple to learn, the
challenge will be getting sufficient practice to learn the patterns in
your daily life
For this -- its up to you and your level of dedication / committment.
I'd recommend to find 30 minutes every day to practice specific skill
elements.
Excels main benefit is its visual user interface -- eg you can click
buttons, drag and drop columns/rows and you can see your data responds.
To help with the R journey, we will introduce (when possible /
appropriate) their corresponding Excel actions.
It will help you understand what R is doing but help you understand the
productivity benefits of R.
\chapter{How to save things on Git}\label{how-to-save-things-on-git}
\begin{itemize}
\tightlist
\item
You can either save on a local site or you can push to a version
sharing repository.
\item
Critical that you get familiar with version sharing site
\end{itemize}
how to connect to github
while all this may seem to new, quite honestly its because we have never
been told good versioning and collaboration practices so we are reliant
on saving to a LAN system, amending the name with versioning control
create a new github repsository in github
go to global settings (not repository settings), go to develrop settings
and click personal access tokens
generate new token, copy (consider saving as you can only see it once)
save token with credentials::set\_github\_pat()
check everything with gitcreds\_get()
git config --global credential.helper `cache --timeout=10000000'
usethis::git\_branch\_default()
check local branch
gert::git\_remote\_ls()
get information
resources
https://rfortherestofus.com/2021/02/how-to-use-git-github-with-r/
\{r\} usethis::use\_git\_remote(``origin'',url=NULL,overwrite=TRUE)
usethis::use\_github() usethis::gh\_token\_help()
usethis::use\_git\_remote(name = ``origin'',url =
``https://github.com/alejandrohagan/learningR.git'',overwrite=TRUE)
gitcreds::gitcreds\_set(url =
``https://github.com/alejandrohagan/learningR.git'')
usethis::use\_github() usethis::git\_default\_branch()
gh::gh\_whoami()
usethis::git\_remotes()
usethis::pr\_push()
usethis::pr\_fetch()
usethis::pr\_pull()
usethis::pr\_init(branch = ``main'')
git config pull.rebase false
usethis::use\_git\_remote(name = ``origin'',url =
``https://github.com/alejandrohagan/learningR.git'',overwrite=TRUE))
• To create a personal access token, call
\texttt{create\_github\_token()} • To store a token for current and
future use, call \texttt{gitcreds::gitcreds\_set()}
5 steps to change GitHub default branch from master to main \textbar{}
R-bloggers
Don't Lose your HEAD over Default Branches \textbar{} R-bloggers
Git: Moving from Master to Main \textbar{} R-bloggers
push \& committ and commenting
How to manipulate \& tidy data
\#\#how to import data----------
read.csv()
read\_csv()
fread()
\#\#how to change column types----
how to create data
seq() runif() sample(data,\# of times, replace,) c() data.frame()
how to create data with basic loops / repitition
types of data
vector data.frame list
some base R basics that will be helpful to you as you read the forums
how to import files
by folder
by website
excel spreadsheet
powerbi model
how to find files by their type
how to append files together
how to automate file importation
file column names
how to change column names
statically
dynamically
best practices when naming columns
how to change column types
statically
dynamically
how to check data structure
-unique
how to clean data
how to shape data
how to subset data
filter
dynamic
static
select