|
| 1 | +% !TEX root = base-r.tex |
| 2 | + |
| 3 | +{\setbeamercolor{block body}{fg = black, bg = white} |
| 4 | +\begin{block}{리스트} |
| 5 | + \centering |
| 6 | + \inlc{l <- list(x = 1:5, y = c('a', 'b'))}\\{\small 리스트는 자료형에 상관없이 여러 개의 원소를 가지는 집합} |
| 7 | + |
| 8 | + \smallskip |
| 9 | + {\color{gray}\hrule} |
| 10 | + |
| 11 | + \smallskip |
| 12 | + \begin{tabular}{*{4}{>{\centering\arraybackslash}m{0.215\linewidth}}} |
| 13 | + \inlc{l[[2]]} & \inlc{l[1]} & \inlc{l\$x} & \inlc{l['y']}\\ |
| 14 | + l의 두번째 원소 & 첫 번째 원소만 있는 새 리스트 & x라는 이름의 원소 & y라는 이름의 원소만 있는 새 리스트. |
| 15 | + \end{tabular} |
| 16 | +\end{block} |
| 17 | +} |
| 18 | + |
| 19 | +\begin{block}{행렬} |
| 20 | + \begin{column}[t]{0.5\linewidth} |
| 21 | + \begin{tabular}{>{\centering\arraybackslash} m{0.65cm} c @{-~~} l} |
| 22 | + \begin{tikzpicture}[scale = 0.3] |
| 23 | + \foreach \x in {0, 1, 2} |
| 24 | + \foreach \y in {0, 2} |
| 25 | + \filldraw[lightgray!65] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 26 | + \foreach \x in {0, 1, 2} |
| 27 | + \filldraw[yellow!75!orange] (\x, 1) rectangle ({\x + 0.8}, {1 + 0.8}); |
| 28 | + \end{tikzpicture} |
| 29 | + & \inlc{m[2, ]} & 열 선택\\ |
| 30 | + \begin{tikzpicture}[scale = 0.3] |
| 31 | + \foreach \y in {0, 1, 2} |
| 32 | + \foreach \x in {1, 2} |
| 33 | + \filldraw[lightgray!65] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 34 | + \foreach \y in {0, 1, 2} |
| 35 | + \filldraw[yellow!75!orange] (0, \y) rectangle ({0 + 0.8}, {\y + 0.8}); |
| 36 | + \end{tikzpicture} |
| 37 | + & \inlc{m[ ,1]} & 행 선택\\ |
| 38 | + \begin{tikzpicture}[scale = 0.3] |
| 39 | + \foreach \x in {0, 1, 2} |
| 40 | + \foreach \y in {0, 1, 2} |
| 41 | + \filldraw[lightgray!65] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 42 | + \filldraw[yellow!75!orange] (2, 1) rectangle ({2 + 0.8}, {1 + 0.8}); |
| 43 | + \end{tikzpicture} |
| 44 | + & \inlc{m[2,3]} & 원소 선택 |
| 45 | + \end{tabular} |
| 46 | + \end{column} |
| 47 | + {\color{gray}\vrule} |
| 48 | + \begin{column}[t]{0.35\linewidth} |
| 49 | + \vspace{-10ex} |
| 50 | + \flushright |
| 51 | + \inl{t(m)}\\ 전치 |
| 52 | + |
| 53 | + \inl{m \%*\% n}\\{ 행렬곱} |
| 54 | + |
| 55 | + \inl{solve(m,n)}\\{ \inl{m*x = n}의 해 찾기} |
| 56 | + \end{column} |
| 57 | +\end{block} |
| 58 | + |
| 59 | +{\setbeamercolor{block body}{fg = black, bg = white} |
| 60 | +\begin{seeblock}{데이터프레임}{dplyr} |
| 61 | + {\fontsize{9pt}{11pt}\selectfont\inlc{df <- data.frame(x = 1:3, y = c('a', 'b', 'c'))}\\모든 원소의 길이가 같은 리스트의 특수한 케이스} |
| 62 | + |
| 63 | + \begin{column}{0.35\linewidth} |
| 64 | + |
| 65 | + \renewcommand{\arraystretch}{1.75} |
| 66 | + \color{secondary} |
| 67 | + \begin{tabular}{| >{\centering\arraybackslash\color{black}} m{0.75cm} | >{\centering\arraybackslash\color{black}} m{0.75cm} |} |
| 68 | + \hline |
| 69 | + \rowcolor{codebg}\color{white} x & \color{white}y\\\hline |
| 70 | + \rowcolor{white} 1 & a\\\hline |
| 71 | + \rowcolor{white} 2 & b\\\hline |
| 72 | + \rowcolor{white} 3 & c\\\hline |
| 73 | + \end{tabular} |
| 74 | + \end{column} |
| 75 | +% |
| 76 | + \begin{column}{0.65\linewidth} |
| 77 | + \vspace{-3ex} |
| 78 | + \begin{center}\textbf{리스트로 자르기}\end{center} |
| 79 | + \begin{tabular}{c >{\centering\arraybackslash} m{0.65cm} c m{0.65cm}} |
| 80 | + \inlc{df\$x} & |
| 81 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 82 | + \foreach \y in {0, 1, 2} |
| 83 | + \filldraw[yellow!75!orange] (0, \y) rectangle ({0 + 0.8}, {\y + 0.8}); |
| 84 | + \filldraw[yellow!70!black] (0, 3) rectangle ({0 + 0.8}, {3 + 0.8}); |
| 85 | + \foreach \y in {0, 1, 2} |
| 86 | + \filldraw[white] (1, \y) rectangle ({1 + 0.8}, {\y + 0.8}); |
| 87 | + \filldraw[codebg] (1, 3) rectangle ({1 + 0.8}, {3 + 0.8}); |
| 88 | + \end{tikzpicture} & |
| 89 | + \inlc{df[[2]]} & |
| 90 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 91 | + \foreach \y in {0, 1, 2} |
| 92 | + \filldraw[yellow!75!orange] (1, \y) rectangle ({1 + 0.8}, {\y + 0.8}); |
| 93 | + \filldraw[yellow!70!black] (1, 3) rectangle ({1 + 0.8}, {3 + 0.8}); |
| 94 | + \foreach \y in {0, 1, 2} |
| 95 | + \filldraw[white] (0, \y) rectangle ({0 + 0.8}, {\y + 0.8}); |
| 96 | + \filldraw[codebg] (0, 3) rectangle ({0 + 0.8}, {3 + 0.8}); |
| 97 | + \end{tikzpicture} |
| 98 | + \end{tabular} |
| 99 | + \vspace{-1.5ex} |
| 100 | + \begin{center} |
| 101 | + \begin{tikzpicture}[remember picture, overlay] |
| 102 | + \draw[darkgray, dotted, very thick, rounded corners] (-3, 0) rectangle (3, -1.5); |
| 103 | + \end{tikzpicture} |
| 104 | + |
| 105 | + \textit{데이터프레임 파악하기} |
| 106 | + |
| 107 | + \smallskip |
| 108 | + \begin{tabular}{c l} |
| 109 | + \inl{view(df)} & 전체 데이터프레임 보기\\ |
| 110 | + \inl{head(df)} & 첫 6열까지만 보기 |
| 111 | + \end{tabular} |
| 112 | + \end{center} |
| 113 | + \end{column} |
| 114 | + |
| 115 | + \bigskip |
| 116 | + \textbf{행렬로 자르기} |
| 117 | + |
| 118 | + \medskip |
| 119 | + \begin{column}{0.33\linewidth} |
| 120 | + \begin{tabular}{c >{\centering\arraybackslash} m{0.65cm}} |
| 121 | + \inlc{df[ ,2]} & |
| 122 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 123 | + \foreach \y in {0, 1, 2} |
| 124 | + \filldraw[yellow!70!orange] (1, \y) rectangle ({1 + 0.8}, {\y + 0.8}); |
| 125 | + \filldraw[yellow!75!black] (1, 3) rectangle ({1 + 0.8}, {3 + 0.8}); |
| 126 | + \foreach \y in {0, 1, 2} |
| 127 | + \filldraw[white] (0, \y) rectangle ({0 + 0.8}, {\y + 0.8}); |
| 128 | + \filldraw[codebg] (0, 3) rectangle ({0 + 0.8}, {3 + 0.8}); |
| 129 | + \end{tikzpicture}\\[0.75ex] |
| 130 | + \inlc{df[2, ]} & |
| 131 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 132 | + \foreach \x in {0, 1} { |
| 133 | + \filldraw[codebg] (\x, 3) rectangle ({\x + 0.8}, {3 + 0.8}); |
| 134 | + \filldraw[white] (\x, 0) rectangle ({\x + 0.8}, {0 + 0.8}); |
| 135 | + \filldraw[white] (\x, 2) rectangle ({\x + 0.8}, {2 + 0.8}); |
| 136 | + \filldraw[yellow!75!orange] (\x, 1) rectangle ({\x + 0.8}, {1 + 0.8}); |
| 137 | + } |
| 138 | + \end{tikzpicture}\\[0.75ex] |
| 139 | + \inlc{df[2,2]} & |
| 140 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 141 | + \foreach \x in {0, 1} { |
| 142 | + \filldraw[codebg] (\x, 3) rectangle ({\x + 0.8}, {3 + 0.8}); |
| 143 | + \foreach \y in {0, 1, 2} |
| 144 | + \filldraw[white] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 145 | + } |
| 146 | + \filldraw[yellow!75!orange] (1, 1) rectangle ({1 + 0.8}, {1 + 0.8}); |
| 147 | + \end{tikzpicture}\\ |
| 148 | + \end{tabular} |
| 149 | + \end{column} |
| 150 | + {\color{gray}{\vrule}} |
| 151 | + \begin{column}{0.24\linewidth} |
| 152 | + \vspace{-13ex} |
| 153 | + |
| 154 | + \inl{nrow(df)}\\열 개수 |
| 155 | + |
| 156 | + \inl{ncol(df)}\\행 개수 |
| 157 | + |
| 158 | + \inl{dim(df)}\\행과 열의 개수 |
| 159 | + \end{column} |
| 160 | + {\color{gray}{\vrule}} |
| 161 | + \begin{column}{0.4\linewidth} |
| 162 | + \vspace{-12ex} |
| 163 | + |
| 164 | + \inl{cbind} - 열로 합치기 |
| 165 | + |
| 166 | + \smallskip |
| 167 | + {\centering |
| 168 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 169 | + \foreach \x in {0, 1} { |
| 170 | + \filldraw[codebg] (\x, 3) rectangle ({\x + 0.8}, {3 + 0.8}); |
| 171 | + \foreach \y in {0, 1, 2} |
| 172 | + \filldraw[white] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 173 | + } |
| 174 | + |
| 175 | + \foreach \y in {0, 1, 2} |
| 176 | + \filldraw[red] (2.5, \y) rectangle ({2.5 + 0.8}, {\y + 0.8}); |
| 177 | + \filldraw[red!70!black] (2.5, 3) rectangle ({2.5 + 0.8}, {3 + 0.8}); |
| 178 | + |
| 179 | + \draw[->, > = stealth', ultra thick, main] (3.75, 1.5) -- (5.35, 1.5); |
| 180 | + |
| 181 | + \foreach \x in {6, 7, 8} { |
| 182 | + \foreach \y in {0, 1, 2} |
| 183 | + \filldraw[green] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 184 | + \filldraw[green!70!black] (\x, 3) rectangle ({\x + 0.8}, {3 + 0.8}); |
| 185 | + } |
| 186 | + \end{tikzpicture}} |
| 187 | + |
| 188 | + \smallskip |
| 189 | + \inl{rbind} - 행으로 합치기 |
| 190 | + |
| 191 | + \smallskip |
| 192 | + {\centering |
| 193 | + \begin{tikzpicture}[xscale = 0.4, yscale = 0.3] |
| 194 | + \foreach \x in {0, 1} { |
| 195 | + \filldraw[codebg] (\x, 3) rectangle ({\x + 0.8}, {3 + 0.8}); |
| 196 | + \foreach \y in {0, 1, 2} |
| 197 | + \filldraw[white] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 198 | + } |
| 199 | + |
| 200 | + \foreach \x in {2.5, 3.5} { |
| 201 | + \filldraw[red] (\x, 1) rectangle ({\x + 0.8}, {1 + 0.8}); |
| 202 | + \filldraw[red!70!black] (\x, 2) rectangle ({\x + 0.8}, {2 + 0.8}); |
| 203 | + } |
| 204 | + |
| 205 | + \draw[->, > = stealth', ultra thick, main] (4.75, 1.5) -- (6.35, 1.5); |
| 206 | + |
| 207 | + \foreach \x in {7, 8} { |
| 208 | + \foreach \y in {-0.5, 0.5, 1.5, 2.5} |
| 209 | + \filldraw[green] (\x, \y) rectangle ({\x + 0.8}, {\y + 0.8}); |
| 210 | + \filldraw[green!70!black] (\x, 3.5) rectangle ({\x + 0.8}, {3.5 + 0.8}); |
| 211 | + } |
| 212 | + |
| 213 | + \end{tikzpicture}} |
| 214 | + |
| 215 | + \end{column} |
| 216 | +\end{seeblock} |
| 217 | +} |
0 commit comments