|
| 1 | +<!DOCTYPE html> |
| 2 | + |
| 3 | +<html> |
| 4 | + |
| 5 | +<head> |
| 6 | + |
| 7 | +<meta charset="utf-8" /> |
| 8 | +<meta name="generator" content="pandoc" /> |
| 9 | +<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +<title>A (very) short introduction to R</title> |
| 15 | + |
| 16 | +<script src="site_libs/header-attrs-2.23/header-attrs.js"></script> |
| 17 | +<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script> |
| 18 | +<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 19 | +<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" /> |
| 20 | +<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script> |
| 21 | +<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script> |
| 22 | +<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script> |
| 23 | +<style>h1 {font-size: 34px;} |
| 24 | + h1.title {font-size: 38px;} |
| 25 | + h2 {font-size: 30px;} |
| 26 | + h3 {font-size: 24px;} |
| 27 | + h4 {font-size: 18px;} |
| 28 | + h5 {font-size: 16px;} |
| 29 | + h6 {font-size: 12px;} |
| 30 | + code {color: inherit; background-color: rgba(0, 0, 0, 0.04);} |
| 31 | + pre:not([class]) { background-color: white }</style> |
| 32 | +<script src="site_libs/navigation-1.1/tabsets.js"></script> |
| 33 | +<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" /> |
| 34 | +<script src="site_libs/highlightjs-9.12.0/highlight.js"></script> |
| 35 | +<link href="site_libs/font-awesome-6.4.0/css/all.min.css" rel="stylesheet" /> |
| 36 | +<link href="site_libs/font-awesome-6.4.0/css/v4-shims.min.css" rel="stylesheet" /> |
| 37 | + |
| 38 | +<style type="text/css"> |
| 39 | + code{white-space: pre-wrap;} |
| 40 | + span.smallcaps{font-variant: small-caps;} |
| 41 | + span.underline{text-decoration: underline;} |
| 42 | + div.column{display: inline-block; vertical-align: top; width: 50%;} |
| 43 | + div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} |
| 44 | + ul.task-list{list-style: none;} |
| 45 | + </style> |
| 46 | + |
| 47 | +<style type="text/css">code{white-space: pre;}</style> |
| 48 | +<script type="text/javascript"> |
| 49 | +if (window.hljs) { |
| 50 | + hljs.configure({languages: []}); |
| 51 | + hljs.initHighlightingOnLoad(); |
| 52 | + if (document.readyState && document.readyState === "complete") { |
| 53 | + window.setTimeout(function() { hljs.initHighlighting(); }, 0); |
| 54 | + } |
| 55 | +} |
| 56 | +</script> |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +<style type = "text/css"> |
| 67 | +.main-container { |
| 68 | + max-width: 940px; |
| 69 | + margin-left: auto; |
| 70 | + margin-right: auto; |
| 71 | +} |
| 72 | +img { |
| 73 | + max-width:100%; |
| 74 | +} |
| 75 | +.tabbed-pane { |
| 76 | + padding-top: 12px; |
| 77 | +} |
| 78 | +.html-widget { |
| 79 | + margin-bottom: 20px; |
| 80 | +} |
| 81 | +button.code-folding-btn:focus { |
| 82 | + outline: none; |
| 83 | +} |
| 84 | +summary { |
| 85 | + display: list-item; |
| 86 | +} |
| 87 | +details > summary > p:only-child { |
| 88 | + display: inline; |
| 89 | +} |
| 90 | +pre code { |
| 91 | + padding: 0; |
| 92 | +} |
| 93 | +</style> |
| 94 | + |
| 95 | + |
| 96 | +<style type="text/css"> |
| 97 | +.dropdown-submenu { |
| 98 | + position: relative; |
| 99 | +} |
| 100 | +.dropdown-submenu>.dropdown-menu { |
| 101 | + top: 0; |
| 102 | + left: 100%; |
| 103 | + margin-top: -6px; |
| 104 | + margin-left: -1px; |
| 105 | + border-radius: 0 6px 6px 6px; |
| 106 | +} |
| 107 | +.dropdown-submenu:hover>.dropdown-menu { |
| 108 | + display: block; |
| 109 | +} |
| 110 | +.dropdown-submenu>a:after { |
| 111 | + display: block; |
| 112 | + content: " "; |
| 113 | + float: right; |
| 114 | + width: 0; |
| 115 | + height: 0; |
| 116 | + border-color: transparent; |
| 117 | + border-style: solid; |
| 118 | + border-width: 5px 0 5px 5px; |
| 119 | + border-left-color: #cccccc; |
| 120 | + margin-top: 5px; |
| 121 | + margin-right: -10px; |
| 122 | +} |
| 123 | +.dropdown-submenu:hover>a:after { |
| 124 | + border-left-color: #adb5bd; |
| 125 | +} |
| 126 | +.dropdown-submenu.pull-left { |
| 127 | + float: none; |
| 128 | +} |
| 129 | +.dropdown-submenu.pull-left>.dropdown-menu { |
| 130 | + left: -100%; |
| 131 | + margin-left: 10px; |
| 132 | + border-radius: 6px 0 6px 6px; |
| 133 | +} |
| 134 | +</style> |
| 135 | + |
| 136 | +<script type="text/javascript"> |
| 137 | +// manage active state of menu based on current page |
| 138 | +$(document).ready(function () { |
| 139 | + // active menu anchor |
| 140 | + href = window.location.pathname |
| 141 | + href = href.substr(href.lastIndexOf('/') + 1) |
| 142 | + if (href === "") |
| 143 | + href = "index.html"; |
| 144 | + var menuAnchor = $('a[href="' + href + '"]'); |
| 145 | + |
| 146 | + // mark the anchor link active (and if it's in a dropdown, also mark that active) |
| 147 | + var dropdown = menuAnchor.closest('li.dropdown'); |
| 148 | + if (window.bootstrap) { // Bootstrap 4+ |
| 149 | + menuAnchor.addClass('active'); |
| 150 | + dropdown.find('> .dropdown-toggle').addClass('active'); |
| 151 | + } else { // Bootstrap 3 |
| 152 | + menuAnchor.parent().addClass('active'); |
| 153 | + dropdown.addClass('active'); |
| 154 | + } |
| 155 | + |
| 156 | + // Navbar adjustments |
| 157 | + var navHeight = $(".navbar").first().height() + 15; |
| 158 | + var style = document.createElement('style'); |
| 159 | + var pt = "padding-top: " + navHeight + "px; "; |
| 160 | + var mt = "margin-top: -" + navHeight + "px; "; |
| 161 | + var css = ""; |
| 162 | + // offset scroll position for anchor links (for fixed navbar) |
| 163 | + for (var i = 1; i <= 6; i++) { |
| 164 | + css += ".section h" + i + "{ " + pt + mt + "}\n"; |
| 165 | + } |
| 166 | + style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css; |
| 167 | + document.head.appendChild(style); |
| 168 | +}); |
| 169 | +</script> |
| 170 | + |
| 171 | +<!-- tabsets --> |
| 172 | + |
| 173 | +<style type="text/css"> |
| 174 | +.tabset-dropdown > .nav-tabs { |
| 175 | + display: inline-table; |
| 176 | + max-height: 500px; |
| 177 | + min-height: 44px; |
| 178 | + overflow-y: auto; |
| 179 | + border: 1px solid #ddd; |
| 180 | + border-radius: 4px; |
| 181 | +} |
| 182 | + |
| 183 | +.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before { |
| 184 | + content: "\e259"; |
| 185 | + font-family: 'Glyphicons Halflings'; |
| 186 | + display: inline-block; |
| 187 | + padding: 10px; |
| 188 | + border-right: 1px solid #ddd; |
| 189 | +} |
| 190 | + |
| 191 | +.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before { |
| 192 | + content: "\e258"; |
| 193 | + font-family: 'Glyphicons Halflings'; |
| 194 | + border: none; |
| 195 | +} |
| 196 | + |
| 197 | +.tabset-dropdown > .nav-tabs > li.active { |
| 198 | + display: block; |
| 199 | +} |
| 200 | + |
| 201 | +.tabset-dropdown > .nav-tabs > li > a, |
| 202 | +.tabset-dropdown > .nav-tabs > li > a:focus, |
| 203 | +.tabset-dropdown > .nav-tabs > li > a:hover { |
| 204 | + border: none; |
| 205 | + display: inline-block; |
| 206 | + border-radius: 4px; |
| 207 | + background-color: transparent; |
| 208 | +} |
| 209 | + |
| 210 | +.tabset-dropdown > .nav-tabs.nav-tabs-open > li { |
| 211 | + display: block; |
| 212 | + float: none; |
| 213 | +} |
| 214 | + |
| 215 | +.tabset-dropdown > .nav-tabs > li { |
| 216 | + display: none; |
| 217 | +} |
| 218 | +</style> |
| 219 | + |
| 220 | +<!-- code folding --> |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | +</head> |
| 226 | + |
| 227 | +<body> |
| 228 | + |
| 229 | + |
| 230 | +<div class="container-fluid main-container"> |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | +<div class="navbar navbar-default navbar-fixed-top" role="navigation"> |
| 236 | + <div class="container"> |
| 237 | + <div class="navbar-header"> |
| 238 | + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar"> |
| 239 | + <span class="icon-bar"></span> |
| 240 | + <span class="icon-bar"></span> |
| 241 | + <span class="icon-bar"></span> |
| 242 | + </button> |
| 243 | + <a class="navbar-brand" href="index.html">The swirl Course Network</a> |
| 244 | + </div> |
| 245 | + <div id="navbar" class="navbar-collapse collapse"> |
| 246 | + <ul class="nav navbar-nav"> |
| 247 | + <li> |
| 248 | + <a href="index.html">Home</a> |
| 249 | +</li> |
| 250 | +<li class="dropdown"> |
| 251 | + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> |
| 252 | + Browse Courses |
| 253 | + |
| 254 | + <span class="caret"></span> |
| 255 | + </a> |
| 256 | + <ul class="dropdown-menu" role="menu"> |
| 257 | + <li> |
| 258 | + <a href="title.html">By Title</a> |
| 259 | + </li> |
| 260 | + <li class="divider"></li> |
| 261 | + <li> |
| 262 | + <a href="surname.html">By Author's Name</a> |
| 263 | + </li> |
| 264 | + </ul> |
| 265 | +</li> |
| 266 | +<li> |
| 267 | + <a href="http://swirlstats.com/swirlify">Write a swirl Course</a> |
| 268 | +</li> |
| 269 | +<li> |
| 270 | + <a href="http://swirlstats.com">swirl Main Site</a> |
| 271 | +</li> |
| 272 | + </ul> |
| 273 | + <ul class="nav navbar-nav navbar-right"> |
| 274 | + <li> |
| 275 | + <a href="https://github.com/swirldev/scn"> |
| 276 | + <span class="fa fa-github fa-lg"></span> |
| 277 | + |
| 278 | + </a> |
| 279 | +</li> |
| 280 | + </ul> |
| 281 | + </div><!--/.nav-collapse --> |
| 282 | + </div><!--/.container --> |
| 283 | +</div><!--/.navbar --> |
| 284 | + |
| 285 | +<div id="header"> |
| 286 | + |
| 287 | + |
| 288 | + |
| 289 | +<h1 class="title toc-ignore">A (very) short introduction to R</h1> |
| 290 | + |
| 291 | +</div> |
| 292 | + |
| 293 | + |
| 294 | +<div id="author" class="section level3"> |
| 295 | +<h3>Author</h3> |
| 296 | +<ul> |
| 297 | +<li>Claudia Brauer</li> |
| 298 | +</ul> |
| 299 | +</div> |
| 300 | +<div id="co-authors" class="section level3"> |
| 301 | +<h3>Co-Authors</h3> |
| 302 | +<ul> |
| 303 | +<li>Paul Torfs</li> |
| 304 | +</ul> |
| 305 | +</div> |
| 306 | +<div id="description" class="section level3"> |
| 307 | +<h3>Description</h3> |
| 308 | +<p>This course is the swirl version of <a |
| 309 | +href="https://github.com/ClaudiaBrauer/A-very-short-introduction-to-R/blob/master/documents/A%20(very)%20short%20introduction%20to%20R.pdf">A |
| 310 | +(very) short introduction to R</a>. This document has 10 pages of |
| 311 | +background and exercises and 2 pages listing useful functions (to use as |
| 312 | +a reference). Working through this tutorial takes 1 to 2 hours |
| 313 | +(depending on your background).</p> |
| 314 | +<p>Instead of reading the pdf and doing the ToDo exercises, you can also |
| 315 | +go through the text and exercises interactively, using swirl. The |
| 316 | +contents are the same (with a few exceptions), so you can open the pdf |
| 317 | +version alongside to look up how to do something you learned before or |
| 318 | +browse through the references on the last two pages.</p> |
| 319 | +<p>If you find any errors, please let me know on the <a |
| 320 | +href="https://github.com/ClaudiaBrauer/A-very-short-introduction-to-R/issues">issues |
| 321 | +page</a>.</p> |
| 322 | +</div> |
| 323 | +<div id="installation" class="section level3"> |
| 324 | +<h3>Installation</h3> |
| 325 | +<pre class="r"><code>swirl::install_course("A_(very)_short_introduction_to_R")</code></pre> |
| 326 | +<div id="manual-installation" class="section level4"> |
| 327 | +<h4>Manual Installation</h4> |
| 328 | +<ol style="list-style-type: decimal"> |
| 329 | +<li>Download <a |
| 330 | +href="https://github.com/ClaudiaBrauer/A-very-short-introduction-to-R/blob/master/documents/A_(very)_short_introduction_to_R.swc">this</a> |
| 331 | +file.</li> |
| 332 | +<li>Run <code>swirl::install_course()</code> in the R console.</li> |
| 333 | +<li>Select the file you just downloaded.</li> |
| 334 | +</ol> |
| 335 | +</div> |
| 336 | +</div> |
| 337 | +<div id="website" class="section level3"> |
| 338 | +<h3>Website</h3> |
| 339 | +<ul> |
| 340 | +<li><a |
| 341 | +href="https://github.com/ClaudiaBrauer/A-very-short-introduction-to-R" |
| 342 | +class="uri">https://github.com/ClaudiaBrauer/A-very-short-introduction-to-R</a></li> |
| 343 | +</ul> |
| 344 | +</div> |
| 345 | + |
| 346 | + |
| 347 | + |
| 348 | + |
| 349 | +</div> |
| 350 | + |
| 351 | +<script> |
| 352 | + |
| 353 | +// add bootstrap table styles to pandoc tables |
| 354 | +function bootstrapStylePandocTables() { |
| 355 | + $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed'); |
| 356 | +} |
| 357 | +$(document).ready(function () { |
| 358 | + bootstrapStylePandocTables(); |
| 359 | +}); |
| 360 | + |
| 361 | + |
| 362 | +</script> |
| 363 | + |
| 364 | +<!-- tabsets --> |
| 365 | + |
| 366 | +<script> |
| 367 | +$(document).ready(function () { |
| 368 | + window.buildTabsets("TOC"); |
| 369 | +}); |
| 370 | + |
| 371 | +$(document).ready(function () { |
| 372 | + $('.tabset-dropdown > .nav-tabs > li').click(function () { |
| 373 | + $(this).parent().toggleClass('nav-tabs-open'); |
| 374 | + }); |
| 375 | +}); |
| 376 | +</script> |
| 377 | + |
| 378 | +<!-- code folding --> |
| 379 | + |
| 380 | + |
| 381 | +<!-- dynamically load mathjax for compatibility with self-contained --> |
| 382 | +<script> |
| 383 | + (function () { |
| 384 | + var script = document.createElement("script"); |
| 385 | + script.type = "text/javascript"; |
| 386 | + script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; |
| 387 | + document.getElementsByTagName("head")[0].appendChild(script); |
| 388 | + })(); |
| 389 | +</script> |
| 390 | + |
| 391 | +</body> |
| 392 | +</html> |
0 commit comments