<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="generator" content="pandoc" /> <meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> <title>gt-tables.knit</title> <script src="gt-tables_files/header-attrs-2.11/header-attrs.js"></script> <script src="gt-tables_files/jquery-3.6.0/jquery-3.6.0.min.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link href="gt-tables_files/bootstrap-3.3.5/css/readable.min.css" rel="stylesheet" /> <script src="gt-tables_files/bootstrap-3.3.5/js/bootstrap.min.js"></script> <script src="gt-tables_files/bootstrap-3.3.5/shim/html5shiv.min.js"></script> <script src="gt-tables_files/bootstrap-3.3.5/shim/respond.min.js"></script> <style>h1 {font-size: 34px;} h1.title {font-size: 38px;} h2 {font-size: 30px;} h3 {font-size: 24px;} h4 {font-size: 18px;} h5 {font-size: 16px;} h6 {font-size: 12px;} code {color: inherit; background-color: rgba(0, 0, 0, 0.04);} pre:not([class]) { background-color: white }</style> <script src="gt-tables_files/jqueryui-1.11.4/jquery-ui.min.js"></script> <link href="gt-tables_files/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" /> <script src="gt-tables_files/tocify-1.9.1/jquery.tocify.js"></script> <script src="gt-tables_files/navigation-1.1/tabsets.js"></script> <link href="gt-tables_files/pagedtable-1.1/css/pagedtable.css" rel="stylesheet" /> <script src="gt-tables_files/pagedtable-1.1/js/pagedtable.js"></script> <script src="gt-tables_files/clipboard-2.0.6/clipboard.min.js"></script> <link href="gt-tables_files/xaringanExtra-clipboard-0.2.6/xaringanExtra-clipboard.css" rel="stylesheet" /> <script src="gt-tables_files/xaringanExtra-clipboard-0.2.6/xaringanExtra-clipboard.js"></script> <script>window.xaringanExtraClipboard(null, {"button":"<i class=\"fa fa-clipboard\"><\/i>","success":"<i class=\"fa fa-check\" style=\"color: #90BE6D\"><\/i>","error":"<i class=\"fa fa-times-circle\" style=\"color: #F94144\"><\/i>"})</script> <link href="gt-tables_files/font-awesome-5.1.0/css/all.css" rel="stylesheet" /> <link href="gt-tables_files/font-awesome-5.1.0/css/v4-shims.css" rel="stylesheet" /> <style type="text/css"> code{white-space: pre-wrap;} span.smallcaps{font-variant: small-caps;} span.underline{text-decoration: underline;} div.column{display: inline-block; vertical-align: top; width: 50%;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} </style> <style type="text/css"> code { white-space: pre; } .sourceCode { overflow: visible; } </style> <style type="text/css" data-origin="pandoc"> pre > code.sourceCode { white-space: pre; position: relative; } pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } pre > code.sourceCode > span:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode > span { color: inherit; text-decoration: inherit; } div.sourceCode { margin: 1em 0; } pre.sourceCode { margin: 0; } @media screen { div.sourceCode { overflow: auto; } } @media print { pre > code.sourceCode { white-space: pre-wrap; } pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } } pre.numberSource code { counter-reset: source-line 0; } pre.numberSource code > span { position: relative; left: -4em; counter-increment: source-line; } pre.numberSource code > span > a:first-child::before { content: counter(source-line); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; padding: 0 4px; width: 4em; color: #aaaaaa; } pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } div.sourceCode { } @media screen { pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } } code span.al { color: #ff0000; font-weight: bold; } /* Alert */ code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ code span.at { color: #7d9029; } /* Attribute */ code span.bn { color: #40a070; } /* BaseN */ code span.bu { } /* BuiltIn */ code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ code span.ch { color: #4070a0; } /* Char */ code span.cn { color: #880000; } /* Constant */ code span.co { color: #60a0b0; font-style: italic; } /* Comment */ code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ code span.do { color: #ba2121; font-style: italic; } /* Documentation */ code span.dt { color: #902000; } /* DataType */ code span.dv { color: #40a070; } /* DecVal */ code span.er { color: #ff0000; font-weight: bold; } /* Error */ code span.ex { } /* Extension */ code span.fl { color: #40a070; } /* Float */ code span.fu { color: #06287e; } /* Function */ code span.im { } /* Import */ code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ code span.kw { color: #007020; font-weight: bold; } /* Keyword */ code span.op { color: #666666; } /* Operator */ code span.ot { color: #007020; } /* Other */ code span.pp { color: #bc7a00; } /* Preprocessor */ code span.sc { color: #4070a0; } /* SpecialChar */ code span.ss { color: #bb6688; } /* SpecialString */ code span.st { color: #4070a0; } /* String */ code span.va { color: #19177c; } /* Variable */ code span.vs { color: #4070a0; } /* VerbatimString */ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ </style> <script> // apply pandoc div.sourceCode style to pre.sourceCode instead (function() { var sheets = document.styleSheets; for (var i = 0; i < sheets.length; i++) { if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; try { var rules = sheets[i].cssRules; } catch (e) { continue; } for (var j = 0; j < rules.length; j++) { var rule = rules[j]; // check if there is a div.sourceCode rule if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") continue; var style = rule.style.cssText; // check if color or background-color is set if (rule.style.color === '' && rule.style.backgroundColor === '') continue; // replace div.sourceCode by a pre.sourceCode rule sheets[i].deleteRule(j); sheets[i].insertRule('pre.sourceCode{' + style + '}', j); } } })(); </script> <link rel="stylesheet" href="styles/style.css" type="text/css" /> <style type = "text/css"> .main-container { max-width: 940px; margin-left: auto; margin-right: auto; } img { max-width:100%; } .tabbed-pane { padding-top: 12px; } .html-widget { margin-bottom: 20px; } button.code-folding-btn:focus { outline: none; } summary { display: list-item; } pre code { padding: 0; } </style> <!-- tabsets --> <style type="text/css"> .tabset-dropdown > .nav-tabs { display: inline-table; max-height: 500px; min-height: 44px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; } .tabset-dropdown > .nav-tabs > li.active:before { content: ""; font-family: 'Glyphicons Halflings'; display: inline-block; padding: 10px; border-right: 1px solid #ddd; } .tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before { content: ""; border: none; } .tabset-dropdown > .nav-tabs.nav-tabs-open:before { content: ""; font-family: 'Glyphicons Halflings'; display: inline-block; padding: 10px; border-right: 1px solid #ddd; } .tabset-dropdown > .nav-tabs > li.active { display: block; } .tabset-dropdown > .nav-tabs > li > a, .tabset-dropdown > .nav-tabs > li > a:focus, .tabset-dropdown > .nav-tabs > li > a:hover { border: none; display: inline-block; border-radius: 4px; background-color: transparent; } .tabset-dropdown > .nav-tabs.nav-tabs-open > li { display: block; float: none; } .tabset-dropdown > .nav-tabs > li { display: none; } </style> <!-- code folding --> <style type="text/css"> #TOC { margin: 25px 0px 20px 0px; } @media (max-width: 768px) { #TOC { position: relative; width: 100%; } } @media print { .toc-content { /* see https://github.com/w3c/csswg-drafts/issues/4434 */ float: right; } } .toc-content { padding-left: 30px; padding-right: 40px; } div.main-container { max-width: 1200px; } div.tocify { width: 20%; max-width: 260px; max-height: 85%; } @media (min-width: 768px) and (max-width: 991px) { div.tocify { width: 25%; } } @media (max-width: 767px) { div.tocify { width: 100%; max-width: none; } } .tocify ul, .tocify li { line-height: 20px; } .tocify-subheader .tocify-item { font-size: 0.90em; } .tocify .list-group-item { border-radius: 0px; } </style> </head> <body> <div class="container-fluid main-container"> <!-- setup 3col/9col grid for toc_float and main content --> <div class="row"> <div class="col-xs-12 col-sm-4 col-md-3"> <div id="TOC" class="tocify"> </div> </div> <div class="toc-content col-xs-12 col-sm-8 col-md-9"> <br><br> <center> <p style="font-size: 26px; font-weight:bold; align:center;color:rgb(69, 130, 236)"> Datensätze bändigen & visualisieren mit R</p> <br> <p style="font-size: 24px; align:center"> Benedikt Philipp Kleer <br> 11. Oktober 2021</p> <hr /> <br> </center> <div id="header"> </div> <div id="tabellen-publizierbar-erstellen-mit-gt" class="section level2"> <h2>Tabellen publizierbar erstellen mit <code>gt</code></h2> <p>Das <em>package</em> <code>gt</code> (<em>grammar of tables</em>) inkludiert hilfreiche Funktionen, um Tabellen aus R in ein Format zu exportieren, das in wissenschaftlichen Arbeiten oder bei Präsentationen genutzt werden kann.</p> <p>Das Paket ist umfassend und hier werden nur einführende Schritte dargestellt, die aber für erste Projekte im BA-Studium hilfreich sind. Die genaue Dokumentation findet sich in der <a href="https://gt.rstudio.com/">Benutzerdokumentation</a>.</p> <p>Die generelle Funktionslogik erfolgt bei <code>gt</code> wie folgt:</p> <center> <img src="pics/gt.svg" title="fig:" alt="Aufbau-Logik eines tables in gt" /> </center> <p>All diese verschiedenen Felder können einzeln angesprochen werden und verändert werden.</p> <p>Bevor wir nun mit den Beispielen starten, müssen wir das <em>package</em> selbst laden als auch <code>tidyverse</code>.</p> <div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># falls noch nicht installiert</span></span> <span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="co"># install.packages("gt", </span></span> <span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="co"># dependencies = TRUE</span></span> <span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># )</span></span> <span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a></span> <span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="co"># install.packages("tidyverse",</span></span> <span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co"># dependencies = TRUE</span></span> <span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="co"># )</span></span> <span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span> <span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">"gt"</span>)</span> <span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">"tidyverse"</span>)</span></code></pre></div> </div> <div id="eine-einfache-tabelle" class="section level2"> <h2>Eine einfache Tabelle</h2> <p>Bevor wir nun Kreuztabellen darstellen, machen wir eine einfache Tabelle. Wir wollen zum Beispiel die Häufigkeiten für die <em>Studienmotivation</em> ausgeben lassen (<code>mot</code>).</p> <div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">table</span>(uni<span class="sc">$</span>mot)</span></code></pre></div> <pre><code> 0 1 2 3 4 5 6 7 8 9 105 93 81 110 116 93 88 108 91 115 </code></pre> <p>Zuerst müssen wir mit <code>tidyverse</code> ein <em>tibble</em> schaffen, dass wir an <code>gt</code> übergeben können. Dazu wählen wir aus dem Datensatz die Variable <code>mot</code> aus, gruppieren die Daten nach <code>mot</code> und bilden dann mit summarize die jeweilige Summe unter den Ausprägungen der Variable <code>mot</code> (Funktion <code>n()</code>). Mit <code>gt()</code> erstellen wir dann die Tabelle:</p> <div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span> </span> <span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(mot) <span class="sc">%>%</span> </span> <span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(mot) <span class="sc">%>%</span> </span> <span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span> <span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> <div id="ersisutghe" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #ersisutghe .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #ersisutghe .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ersisutghe .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #ersisutghe .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #ersisutghe .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ersisutghe .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ersisutghe .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #ersisutghe .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #ersisutghe .gt_column_spanner_outer:first-child { padding-left: 0; } #ersisutghe .gt_column_spanner_outer:last-child { padding-right: 0; } #ersisutghe .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #ersisutghe .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #ersisutghe .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #ersisutghe .gt_from_md > :first-child { margin-top: 0; } #ersisutghe .gt_from_md > :last-child { margin-bottom: 0; } #ersisutghe .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #ersisutghe .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #ersisutghe .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ersisutghe .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #ersisutghe .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ersisutghe .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #ersisutghe .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #ersisutghe .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ersisutghe .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ersisutghe .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #ersisutghe .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ersisutghe .gt_sourcenote { font-size: 90%; padding: 4px; } #ersisutghe .gt_left { text-align: left; } #ersisutghe .gt_center { text-align: center; } #ersisutghe .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #ersisutghe .gt_font_normal { font-weight: normal; } #ersisutghe .gt_font_bold { font-weight: bold; } #ersisutghe .gt_font_italic { font-style: italic; } #ersisutghe .gt_super { font-size: 65%; } #ersisutghe .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">mot</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">n</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_right">0</td> <td class="gt_row gt_right">105</td></tr> <tr><td class="gt_row gt_right">1</td> <td class="gt_row gt_right">93</td></tr> <tr><td class="gt_row gt_right">2</td> <td class="gt_row gt_right">81</td></tr> <tr><td class="gt_row gt_right">3</td> <td class="gt_row gt_right">110</td></tr> <tr><td class="gt_row gt_right">4</td> <td class="gt_row gt_right">116</td></tr> <tr><td class="gt_row gt_right">5</td> <td class="gt_row gt_right">93</td></tr> <tr><td class="gt_row gt_right">6</td> <td class="gt_row gt_right">88</td></tr> <tr><td class="gt_row gt_right">7</td> <td class="gt_row gt_right">108</td></tr> <tr><td class="gt_row gt_right">8</td> <td class="gt_row gt_right">91</td></tr> <tr><td class="gt_row gt_right">9</td> <td class="gt_row gt_right">115</td></tr> </tbody> </table> </div> <p>Jetzt ist das Format noch etwas unhandlich für Berichte oder Abschlussarbeiten und daher nutzen wir eine weitere Funktion aus <code>tidyverse</code>, nämlich <code>pivot_wider()</code>. Mit <code>pivot_wider()</code> können wir die Tabelle neu ordnen. Hierbei geben wir dann an, dass die Spaltennamen die Ausprägungen von <code>mot</code> sind und die Werte (also der Inhalt der ersten und einzigen Zeile) aus der vorherigen Spalte <code>n</code> entnommen werden.</p> <div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span> </span> <span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(mot) <span class="sc">%>%</span> </span> <span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(mot) <span class="sc">%>%</span> </span> <span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span> <span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> mot,</span> <span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> n</span> <span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> <div id="jigzjgrlrz" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #jigzjgrlrz .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #jigzjgrlrz .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #jigzjgrlrz .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #jigzjgrlrz .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #jigzjgrlrz .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #jigzjgrlrz .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #jigzjgrlrz .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #jigzjgrlrz .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #jigzjgrlrz .gt_column_spanner_outer:first-child { padding-left: 0; } #jigzjgrlrz .gt_column_spanner_outer:last-child { padding-right: 0; } #jigzjgrlrz .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #jigzjgrlrz .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #jigzjgrlrz .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #jigzjgrlrz .gt_from_md > :first-child { margin-top: 0; } #jigzjgrlrz .gt_from_md > :last-child { margin-bottom: 0; } #jigzjgrlrz .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #jigzjgrlrz .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #jigzjgrlrz .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #jigzjgrlrz .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #jigzjgrlrz .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #jigzjgrlrz .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #jigzjgrlrz .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #jigzjgrlrz .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #jigzjgrlrz .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #jigzjgrlrz .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #jigzjgrlrz .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #jigzjgrlrz .gt_sourcenote { font-size: 90%; padding: 4px; } #jigzjgrlrz .gt_left { text-align: left; } #jigzjgrlrz .gt_center { text-align: center; } #jigzjgrlrz .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #jigzjgrlrz .gt_font_normal { font-weight: normal; } #jigzjgrlrz .gt_font_bold { font-weight: bold; } #jigzjgrlrz .gt_font_italic { font-style: italic; } #jigzjgrlrz .gt_super { font-size: 65%; } #jigzjgrlrz .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">0</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_right">105</td> <td class="gt_row gt_right">93</td> <td class="gt_row gt_right">81</td> <td class="gt_row gt_right">110</td> <td class="gt_row gt_right">116</td> <td class="gt_row gt_right">93</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">108</td> <td class="gt_row gt_right">91</td> <td class="gt_row gt_right">115</td></tr> </tbody> </table> </div> <p>Fertig ist die Darstellung der absoluten Häufigkeiten der Variable <code>mot</code>. Dies sieht schon viel schöner aus als in der R Konsole (und ist auch als Bild exportierbar, dazu später mehr). Bevor nun einzelne Formatierungsmöglichkeiten in <code>gt</code> gezeigt werden, gehen wir über zu Kreuztabellen und zur Ausgabe prozentualer Häufigkeiten.</p> </div> <div id="kreuztabelle" class="section level2"> <h2>Kreuztabelle</h2> <p>Wir nehmen wieder ein Beispiel aus dem Trainingsdatensatz <code>uni</code>. Wir möchten eine Kreuztabelle zwischen Studienort (<code>city</code>) und Studienfach (<code>study</code>) erstellen. Wir möchten wissen, wie viele Personen jeweils in den einzelnen Städten die spezifischen Fächer studieren.</p> <div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>example</span></code></pre></div> <pre><code> Gießen Marburg Frankfurt Political Science 70 72 78 Sociology 88 94 81 Educational Science 95 96 74 Psychology 85 88 79</code></pre> <p>Wir wir sehen ist die originäre R Ausgabe nicht gut visuell dargestellt und auch die bisher genutzten Pakete erhöhten zwar die <em>readibility</em> in der Konsole, konnten aber nicht den Export unterstützen. Für die Weiterverwendung in anderen Paketen eignet sich daher das <em>package</em> <code>gt</code>, mit dem wir Bilddateien aus den Tabellen erstellen können.</p> <p>Hierbei greifen wir auf das Paket <code>tidyverse</code> zurück, in dem wir die Daten für das <em>package</em> <code>gt</code> manipulieren. Nehmen wir das Beispiel einer Kreuztabelle zwischen Studienort und Studienfach von oben. Zuerst selektieren wir zur Vereinfachung den Datensatz auf die zwei genutzten Variablen mit <code>select()</code>. Anschließend gruppieren wir die Daten mit <code>group_by()</code>. Danach nutzen wir <code>summarize()</code>, um die Summen der einzelnen Kombinationen zu bilden (also die späteren Zellen der Tabelle). Bevor wir dann die Funktion <code>gt()</code> aufrufen, nutzen wir eine weitere Funktion aus <code>tidyverse</code>, nämlich <code>pivot_wider()</code>.</p> <div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span> </span> <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(study,</span> <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> city</span> <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(city, </span> <span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> study</span> <span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span></span> <span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> city,</span> <span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> n</span> <span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a> )</span></code></pre></div> <div data-pagedtable="false"> <script data-pagedtable-source type="application/json"> {"columns":[{"label":["study"],"name":[1],"type":["fct"],"align":["left"]},{"label":["Gießen"],"name":[2],"type":["int"],"align":["right"]},{"label":["Marburg"],"name":[3],"type":["int"],"align":["right"]},{"label":["Frankfurt"],"name":[4],"type":["int"],"align":["right"]}],"data":[{"1":"Political Science","2":"70","3":"72","4":"78"},{"1":"Sociology","2":"88","3":"94","4":"81"},{"1":"Educational Science","2":"95","3":"96","4":"74"},{"1":"Psychology","2":"85","3":"88","4":"79"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[15],"max":[15]},"pages":{}}} </script> </div> <p>Wir sehen, dass wir nun ein <em>tibble</em> haben, der in der ersten Spalte die Ausprägungen von <code>study</code> hat, und die zweite bis vierte Spalte stellen die Ausprägungen von <code>city</code> dar. In den einzelnen Feldern befindet sich die Summe der einzelnen Paare.</p> </div> <div id="kreuztabelle-mit-gt" class="section level2"> <h2>Kreuztabelle mit <code>gt</code></h2> <p>Als nächstes werden wir jetzt dann die Funktion <code>gt()</code> aufrufen:</p> <div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span> </span> <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(study, </span> <span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> city</span> <span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(city, </span> <span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> study</span> <span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span></span> <span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> city, </span> <span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> n</span> <span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> <div id="ybmjqzwoha" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #ybmjqzwoha .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #ybmjqzwoha .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ybmjqzwoha .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #ybmjqzwoha .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #ybmjqzwoha .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ybmjqzwoha .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ybmjqzwoha .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #ybmjqzwoha .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #ybmjqzwoha .gt_column_spanner_outer:first-child { padding-left: 0; } #ybmjqzwoha .gt_column_spanner_outer:last-child { padding-right: 0; } #ybmjqzwoha .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #ybmjqzwoha .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #ybmjqzwoha .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #ybmjqzwoha .gt_from_md > :first-child { margin-top: 0; } #ybmjqzwoha .gt_from_md > :last-child { margin-bottom: 0; } #ybmjqzwoha .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #ybmjqzwoha .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #ybmjqzwoha .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ybmjqzwoha .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #ybmjqzwoha .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ybmjqzwoha .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #ybmjqzwoha .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #ybmjqzwoha .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ybmjqzwoha .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ybmjqzwoha .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #ybmjqzwoha .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ybmjqzwoha .gt_sourcenote { font-size: 90%; padding: 4px; } #ybmjqzwoha .gt_left { text-align: left; } #ybmjqzwoha .gt_center { text-align: center; } #ybmjqzwoha .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #ybmjqzwoha .gt_font_normal { font-weight: normal; } #ybmjqzwoha .gt_font_bold { font-weight: bold; } #ybmjqzwoha .gt_font_italic { font-style: italic; } #ybmjqzwoha .gt_super { font-size: 65%; } #ybmjqzwoha .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">study</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">Political Science</td> <td class="gt_row gt_right">70</td> <td class="gt_row gt_right">72</td> <td class="gt_row gt_right">78</td></tr> <tr><td class="gt_row gt_center">Sociology</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">94</td> <td class="gt_row gt_right">81</td></tr> <tr><td class="gt_row gt_center">Educational Science</td> <td class="gt_row gt_right">95</td> <td class="gt_row gt_right">96</td> <td class="gt_row gt_right">74</td></tr> <tr><td class="gt_row gt_center">Psychology</td> <td class="gt_row gt_right">85</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">79</td></tr> </tbody> </table> </div> <p>Nun sehen wir die erste mit <code>gt</code> erzeugte Kreuztabelle. Bevor wir nun in die Formatierung der Tabelle gehen, schaffen wir erst prozentuale Ausgaben. <strong>Wichtig hierbei</strong>: Die Konvention ist, dass wir Spaltenprozente erstellen.</p> <div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span></span> <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(study,</span> <span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a> city</span> <span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(city,</span> <span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a> study</span> <span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span></span> <span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span></span> <span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">prop =</span> n <span class="sc">/</span> <span class="fu">sum</span>(n))<span class="sc">%>%</span> <span class="co"># neue prozentualer Anteil nach Spalten!</span></span> <span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> city, </span> <span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> prop</span> <span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> <div id="jdaiyhtqik" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #jdaiyhtqik .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #jdaiyhtqik .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #jdaiyhtqik .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #jdaiyhtqik .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #jdaiyhtqik .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #jdaiyhtqik .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #jdaiyhtqik .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #jdaiyhtqik .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #jdaiyhtqik .gt_column_spanner_outer:first-child { padding-left: 0; } #jdaiyhtqik .gt_column_spanner_outer:last-child { padding-right: 0; } #jdaiyhtqik .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #jdaiyhtqik .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #jdaiyhtqik .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #jdaiyhtqik .gt_from_md > :first-child { margin-top: 0; } #jdaiyhtqik .gt_from_md > :last-child { margin-bottom: 0; } #jdaiyhtqik .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #jdaiyhtqik .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #jdaiyhtqik .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #jdaiyhtqik .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #jdaiyhtqik .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #jdaiyhtqik .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #jdaiyhtqik .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #jdaiyhtqik .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #jdaiyhtqik .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #jdaiyhtqik .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #jdaiyhtqik .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #jdaiyhtqik .gt_sourcenote { font-size: 90%; padding: 4px; } #jdaiyhtqik .gt_left { text-align: left; } #jdaiyhtqik .gt_center { text-align: center; } #jdaiyhtqik .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #jdaiyhtqik .gt_font_normal { font-weight: normal; } #jdaiyhtqik .gt_font_bold { font-weight: bold; } #jdaiyhtqik .gt_font_italic { font-style: italic; } #jdaiyhtqik .gt_super { font-size: 65%; } #jdaiyhtqik .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">study</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">n</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">Political Science</td> <td class="gt_row gt_right">70</td> <td class="gt_row gt_right">0.2071006</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Sociology</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">0.2603550</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Educational Science</td> <td class="gt_row gt_right">95</td> <td class="gt_row gt_right">0.2810651</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Psychology</td> <td class="gt_row gt_right">85</td> <td class="gt_row gt_right">0.2514793</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Political Science</td> <td class="gt_row gt_right">72</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2057143</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Sociology</td> <td class="gt_row gt_right">94</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2685714</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Educational Science</td> <td class="gt_row gt_right">96</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2742857</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Psychology</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2514286</td> <td class="gt_row gt_right">NA</td></tr> <tr><td class="gt_row gt_center">Political Science</td> <td class="gt_row gt_right">78</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2500000</td></tr> <tr><td class="gt_row gt_center">Sociology</td> <td class="gt_row gt_right">81</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2596154</td></tr> <tr><td class="gt_row gt_center">Educational Science</td> <td class="gt_row gt_right">74</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2371795</td></tr> <tr><td class="gt_row gt_center">Psychology</td> <td class="gt_row gt_right">79</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">NA</td> <td class="gt_row gt_right">0.2532051</td></tr> </tbody> </table> </div> <p>Das Ergebnis irritiert etwas, denn wir haben doppelte Spalten. Dies liegt daran, dass wir weiterhin noch die absoluten Zahlen als Spalte (<code>n</code>) mit übergeben haben. Diese schließen wir einfach über <code>subset()</code> aus:</p> <div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>uni <span class="sc">%>%</span></span> <span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(study, </span> <span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a> city</span> <span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(city,</span> <span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a> study</span> <span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span></span> <span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span></span> <span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">prop =</span> n <span class="sc">/</span> <span class="fu">sum</span>(n))<span class="sc">%>%</span> <span class="co"># neue prozentualer Anteil nach Spalten!</span></span> <span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">subset</span>(<span class="at">select =</span> <span class="fu">c</span>(<span class="st">"city"</span>, </span> <span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="st">"study"</span>,</span> <span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="st">"prop"</span></span> <span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> <span class="co"># die zwei Variablen und prop! </span></span> <span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> city, </span> <span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> prop</span> <span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> <div id="ypmpqshedm" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #ypmpqshedm .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #ypmpqshedm .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ypmpqshedm .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #ypmpqshedm .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #ypmpqshedm .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ypmpqshedm .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ypmpqshedm .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #ypmpqshedm .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #ypmpqshedm .gt_column_spanner_outer:first-child { padding-left: 0; } #ypmpqshedm .gt_column_spanner_outer:last-child { padding-right: 0; } #ypmpqshedm .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #ypmpqshedm .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #ypmpqshedm .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #ypmpqshedm .gt_from_md > :first-child { margin-top: 0; } #ypmpqshedm .gt_from_md > :last-child { margin-bottom: 0; } #ypmpqshedm .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #ypmpqshedm .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #ypmpqshedm .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ypmpqshedm .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #ypmpqshedm .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ypmpqshedm .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #ypmpqshedm .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #ypmpqshedm .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ypmpqshedm .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ypmpqshedm .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #ypmpqshedm .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ypmpqshedm .gt_sourcenote { font-size: 90%; padding: 4px; } #ypmpqshedm .gt_left { text-align: left; } #ypmpqshedm .gt_center { text-align: center; } #ypmpqshedm .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #ypmpqshedm .gt_font_normal { font-weight: normal; } #ypmpqshedm .gt_font_bold { font-weight: bold; } #ypmpqshedm .gt_font_italic { font-style: italic; } #ypmpqshedm .gt_super { font-size: 65%; } #ypmpqshedm .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">study</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">Political Science</td> <td class="gt_row gt_right">0.2071006</td> <td class="gt_row gt_right">0.2057143</td> <td class="gt_row gt_right">0.2500000</td></tr> <tr><td class="gt_row gt_center">Sociology</td> <td class="gt_row gt_right">0.2603550</td> <td class="gt_row gt_right">0.2685714</td> <td class="gt_row gt_right">0.2596154</td></tr> <tr><td class="gt_row gt_center">Educational Science</td> <td class="gt_row gt_right">0.2810651</td> <td class="gt_row gt_right">0.2742857</td> <td class="gt_row gt_right">0.2371795</td></tr> <tr><td class="gt_row gt_center">Psychology</td> <td class="gt_row gt_right">0.2514793</td> <td class="gt_row gt_right">0.2514286</td> <td class="gt_row gt_right">0.2532051</td></tr> </tbody> </table> </div> <p>Nun haben wir also eine Kreuztabelle mit absoluten Häufigkeiten und eine mit relativen Häufigkeiten. In den nächsten Schritten wird die Tabelle formatiert.</p> </div> <div id="formatierungen-in-gt" class="section level2"> <h2>Formatierungen in <code>gt</code></h2> <p>Um die Tabellen nun zu formatieren, speichern wir diese zuerst in einem Objekt: Denn R ist objektorientiert! Wir nehmen die absolute Häufigkeitstabelle der Variable <code>mot</code> und die prozentuale Kreuztabelle ziwschen <code>city</code> und <code>study</code>. <strong>Wichtig hierbei</strong>: Erinnere dich an die Abbildung zu Beginn, in der alle einzelnen Bereiche einer <code>gt</code>-Tabelle benannt waren!</p> <div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>single <span class="ot"><-</span> uni <span class="sc">%>%</span> </span> <span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(mot) <span class="sc">%>%</span> </span> <span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(mot) <span class="sc">%>%</span> </span> <span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span> </span> <span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> mot,</span> <span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> n</span> <span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span> <span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a></span> <span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a>cross <span class="ot"><-</span> uni <span class="sc">%>%</span></span> <span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(study,</span> <span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a> city</span> <span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(city, </span> <span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a> study</span> <span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span></span> <span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n =</span> <span class="fu">n</span>()) <span class="sc">%>%</span></span> <span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">prop =</span> n <span class="sc">/</span> <span class="fu">sum</span>(n))<span class="sc">%>%</span> </span> <span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">subset</span>(<span class="at">select =</span> <span class="fu">c</span>(<span class="st">"city"</span>, </span> <span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a> <span class="st">"study"</span>,</span> <span id="cb12-21"><a href="#cb12-21" aria-hidden="true" tabindex="-1"></a> <span class="st">"prop"</span></span> <span id="cb12-22"><a href="#cb12-22" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">pivot_wider</span>(<span class="at">names_from =</span> city,</span> <span id="cb12-25"><a href="#cb12-25" aria-hidden="true" tabindex="-1"></a> <span class="at">values_from =</span> prop</span> <span id="cb12-26"><a href="#cb12-26" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb12-27"><a href="#cb12-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">gt</span>()</span></code></pre></div> </div> <div id="titel-ändern" class="section level2"> <h2>Titel ändern</h2> <p>Zuerst fügen wir der Häufigkeitstabelle nun einen Titel hinzu, damit klar ist, um was für Daten es sich handelt.</p> <div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span> </span> <span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)</span></code></pre></div> <div id="aswzuqhapm" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #aswzuqhapm .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #aswzuqhapm .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #aswzuqhapm .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #aswzuqhapm .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #aswzuqhapm .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #aswzuqhapm .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #aswzuqhapm .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #aswzuqhapm .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #aswzuqhapm .gt_column_spanner_outer:first-child { padding-left: 0; } #aswzuqhapm .gt_column_spanner_outer:last-child { padding-right: 0; } #aswzuqhapm .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #aswzuqhapm .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #aswzuqhapm .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #aswzuqhapm .gt_from_md > :first-child { margin-top: 0; } #aswzuqhapm .gt_from_md > :last-child { margin-bottom: 0; } #aswzuqhapm .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #aswzuqhapm .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #aswzuqhapm .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #aswzuqhapm .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #aswzuqhapm .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #aswzuqhapm .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #aswzuqhapm .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #aswzuqhapm .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #aswzuqhapm .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #aswzuqhapm .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #aswzuqhapm .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #aswzuqhapm .gt_sourcenote { font-size: 90%; padding: 4px; } #aswzuqhapm .gt_left { text-align: left; } #aswzuqhapm .gt_center { text-align: center; } #aswzuqhapm .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #aswzuqhapm .gt_font_normal { font-weight: normal; } #aswzuqhapm .gt_font_bold { font-weight: bold; } #aswzuqhapm .gt_font_italic { font-style: italic; } #aswzuqhapm .gt_super { font-size: 65%; } #aswzuqhapm .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">0</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_right" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_right">105</td> <td class="gt_row gt_right">93</td> <td class="gt_row gt_right">81</td> <td class="gt_row gt_right">110</td> <td class="gt_row gt_right">116</td> <td class="gt_row gt_right">93</td> <td class="gt_row gt_right">88</td> <td class="gt_row gt_right">108</td> <td class="gt_row gt_right">91</td> <td class="gt_row gt_right">115</td></tr> </tbody> </table> </div> </div> <div id="alignment-ändern" class="section level2"> <h2>Alignment ändern</h2> <p>Wie wir sehen, sind die Spalten rechts ausgerichtet, dies können wir ebenfalls ändern und zentrieren es nun:</p> <div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span> </span> <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="st">"Abs. Häufigkeit von Studienmotivation"</span>) <span class="sc">%>%</span> </span> <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="co"># auch möglich: auto, left, right</span></span></code></pre></div> <div id="flickikxpu" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #flickikxpu .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #flickikxpu .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #flickikxpu .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #flickikxpu .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #flickikxpu .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #flickikxpu .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #flickikxpu .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #flickikxpu .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #flickikxpu .gt_column_spanner_outer:first-child { padding-left: 0; } #flickikxpu .gt_column_spanner_outer:last-child { padding-right: 0; } #flickikxpu .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #flickikxpu .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #flickikxpu .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #flickikxpu .gt_from_md > :first-child { margin-top: 0; } #flickikxpu .gt_from_md > :last-child { margin-bottom: 0; } #flickikxpu .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #flickikxpu .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #flickikxpu .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #flickikxpu .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #flickikxpu .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #flickikxpu .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #flickikxpu .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #flickikxpu .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #flickikxpu .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #flickikxpu .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #flickikxpu .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #flickikxpu .gt_sourcenote { font-size: 90%; padding: 4px; } #flickikxpu .gt_left { text-align: left; } #flickikxpu .gt_center { text-align: center; } #flickikxpu .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #flickikxpu .gt_font_normal { font-weight: normal; } #flickikxpu .gt_font_bold { font-weight: bold; } #flickikxpu .gt_font_italic { font-style: italic; } #flickikxpu .gt_super { font-size: 65%; } #flickikxpu .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88</td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> </table> </div> </div> <div id="quelle-fußnote-hinzufügen" class="section level2"> <h2>Quelle & Fußnote hinzufügen</h2> <p>Oft werden unter Tabellen Quellen oder Anmerkungen angegeben, dies können wir auch ganz einfach mit <code>gt</code>machen:</p> <div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span></span> <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)) <span class="sc">%>%</span> </span> <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="sc">%>%</span> </span> <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span></span> <span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="fu">md</span>(<span class="st">"Anmerkungen: Mit *md()* können Textformatierungen wie in Markdown vorgenommen **werden**."</span>)) </span></code></pre></div> <div id="gzqnndusre" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #gzqnndusre .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #gzqnndusre .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #gzqnndusre .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #gzqnndusre .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #gzqnndusre .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #gzqnndusre .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #gzqnndusre .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #gzqnndusre .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #gzqnndusre .gt_column_spanner_outer:first-child { padding-left: 0; } #gzqnndusre .gt_column_spanner_outer:last-child { padding-right: 0; } #gzqnndusre .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #gzqnndusre .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #gzqnndusre .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #gzqnndusre .gt_from_md > :first-child { margin-top: 0; } #gzqnndusre .gt_from_md > :last-child { margin-bottom: 0; } #gzqnndusre .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #gzqnndusre .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #gzqnndusre .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #gzqnndusre .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #gzqnndusre .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #gzqnndusre .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #gzqnndusre .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #gzqnndusre .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #gzqnndusre .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #gzqnndusre .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #gzqnndusre .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #gzqnndusre .gt_sourcenote { font-size: 90%; padding: 4px; } #gzqnndusre .gt_left { text-align: left; } #gzqnndusre .gt_center { text-align: center; } #gzqnndusre .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #gzqnndusre .gt_font_normal { font-weight: normal; } #gzqnndusre .gt_font_bold { font-weight: bold; } #gzqnndusre .gt_font_italic { font-style: italic; } #gzqnndusre .gt_super { font-size: 65%; } #gzqnndusre .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88</td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="10">Quelle: eigene Erhebung.</td> </tr> <tr> <td class="gt_sourcenote" colspan="10">Anmerkungen: Mit <em>md()</em> können Textformatierungen wie in Markdown vorgenommen <strong>werden</strong>.</td> </tr> </tfoot> </table> </div> <p>Manchmal möchte man zu einzelnen Werten auch eine Fußnote einfügen. Wir fügen jetzt eine Fußnote zum Wert <em>0</em> ein. Hierbei muss unterschieden werden, ob im <code>cells body</code> oder in den <code>column labels</code> eine Fußnote hinzugefügt werden soll. Wir fügen die erste Fußnote in ein <code>column label</code> ein und die zweite Fußnote in eine Zelle der Tabelle. Wenn wir im <code>column label</code> eine Fußnote hinzufügen wollen, benutzen wir in der Funktion <code>tab_footnote()</code> im Argument <code>locations</code> die Funktion <code>cells_column_labels()</code> und geben unter <code>columns</code> die spezifische Spalte an. Wenn wir in einer Zelle eine Fußnote setzen wollen, nutzen wir im Argument <code>locations</code> die Funktion <code>cells_body()</code> und geben dort in den Argumenten <code>columns</code> und <code>rows</code> die Position(en) an. Dies können auch mehrere sein (mit <code>c()</code> oder <code>1:3</code>):</p> <div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span></span> <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)) <span class="sc">%>%</span> </span> <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="sc">%>%</span> </span> <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span></span> <span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="fu">md</span>(<span class="st">"Anmerkungen: Mit *md()* können Textformatierungen vorgenommen **werden**."</span>)) <span class="sc">%>%</span> </span> <span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"Ein Wert von *0* bedeutet **keinerlei Studienmotivation**."</span>),</span> <span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_column_labels</span>(<span class="at">columns =</span> <span class="st">"0"</span>)</span> <span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"***Dies ist einfach nur ein Test.***"</span>),</span> <span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_body</span>(<span class="at">columns =</span> <span class="dv">7</span>,</span> <span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a> <span class="at">rows =</span> <span class="dv">1</span></span> <span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a> )</span></code></pre></div> <div id="zalhpfgoyv" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #zalhpfgoyv .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #zalhpfgoyv .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #zalhpfgoyv .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #zalhpfgoyv .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #zalhpfgoyv .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #zalhpfgoyv .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #zalhpfgoyv .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #zalhpfgoyv .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #zalhpfgoyv .gt_column_spanner_outer:first-child { padding-left: 0; } #zalhpfgoyv .gt_column_spanner_outer:last-child { padding-right: 0; } #zalhpfgoyv .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #zalhpfgoyv .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #zalhpfgoyv .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #zalhpfgoyv .gt_from_md > :first-child { margin-top: 0; } #zalhpfgoyv .gt_from_md > :last-child { margin-bottom: 0; } #zalhpfgoyv .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #zalhpfgoyv .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #zalhpfgoyv .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #zalhpfgoyv .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #zalhpfgoyv .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #zalhpfgoyv .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #zalhpfgoyv .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #zalhpfgoyv .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #zalhpfgoyv .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #zalhpfgoyv .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #zalhpfgoyv .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #zalhpfgoyv .gt_sourcenote { font-size: 90%; padding: 4px; } #zalhpfgoyv .gt_left { text-align: left; } #zalhpfgoyv .gt_center { text-align: center; } #zalhpfgoyv .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #zalhpfgoyv .gt_font_normal { font-weight: normal; } #zalhpfgoyv .gt_font_bold { font-weight: bold; } #zalhpfgoyv .gt_font_italic { font-style: italic; } #zalhpfgoyv .gt_super { font-size: 65%; } #zalhpfgoyv .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table"> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0<sup class="gt_footnote_marks">1</sup></th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88<sup class="gt_footnote_marks">2</sup></td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="10">Quelle: eigene Erhebung.</td> </tr> <tr> <td class="gt_sourcenote" colspan="10">Anmerkungen: Mit <em>md()</em> können Textformatierungen vorgenommen <strong>werden</strong>.</td> </tr> </tfoot> <tfoot> <tr class="gt_footnotes"> <td colspan="10"> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>1</em> </sup> Ein Wert von <em>0</em> bedeutet <strong>keinerlei Studienmotivation</strong>. <br /> </p> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>2</em> </sup> <em><strong>Dies ist einfach nur ein Test.</strong></em> <br /> </p> </td> </tr> </tfoot> </table> </div> </div> <div id="spaltenbreite-ändern" class="section level2"> <h2>Spaltenbreite ändern</h2> <p>Als kleineres Manko sehen wir jetzt noch, dass die Spalten unterschiedlich breit sind. Dies können wir über <code>cols_width()</code> ändern. Hierbei können wir einzelnen Spalten aufrufen oder einen Bereich an Spalten festlegen. Wir könnten z.B. die Breite von Spalte 4 erhöhen. Hierzu nutzen wir die Hilfsfunktion <code>px()</code>, die die Größe in Pixel angibt.</p> <div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span></span> <span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)) <span class="sc">%>%</span> </span> <span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="sc">%>%</span> </span> <span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span></span> <span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="fu">md</span>(<span class="st">"Anmerkungen: Mit *md()* können Textformatierungen vorgenommen **werden**."</span>)) <span class="sc">%>%</span> </span> <span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"Ein Wert von *0* bedeutet **keinerlei Studienmotivation**."</span>),</span> <span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_column_labels</span>(<span class="at">columns =</span> <span class="st">"0"</span>)</span> <span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"***Dies ist einfach nur ein Test.***"</span>),</span> <span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_body</span>(<span class="at">columns =</span> <span class="dv">7</span>,</span> <span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> <span class="at">rows =</span> <span class="dv">1</span></span> <span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(<span class="dv">4</span> <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">80</span>))</span></code></pre></div> <div id="fufjtblgnp" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #fufjtblgnp .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #fufjtblgnp .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #fufjtblgnp .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #fufjtblgnp .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #fufjtblgnp .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #fufjtblgnp .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #fufjtblgnp .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #fufjtblgnp .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #fufjtblgnp .gt_column_spanner_outer:first-child { padding-left: 0; } #fufjtblgnp .gt_column_spanner_outer:last-child { padding-right: 0; } #fufjtblgnp .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #fufjtblgnp .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #fufjtblgnp .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #fufjtblgnp .gt_from_md > :first-child { margin-top: 0; } #fufjtblgnp .gt_from_md > :last-child { margin-bottom: 0; } #fufjtblgnp .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #fufjtblgnp .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #fufjtblgnp .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #fufjtblgnp .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #fufjtblgnp .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #fufjtblgnp .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #fufjtblgnp .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #fufjtblgnp .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #fufjtblgnp .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #fufjtblgnp .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #fufjtblgnp .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #fufjtblgnp .gt_sourcenote { font-size: 90%; padding: 4px; } #fufjtblgnp .gt_left { text-align: left; } #fufjtblgnp .gt_center { text-align: center; } #fufjtblgnp .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #fufjtblgnp .gt_font_normal { font-weight: normal; } #fufjtblgnp .gt_font_bold { font-weight: bold; } #fufjtblgnp .gt_font_italic { font-style: italic; } #fufjtblgnp .gt_super { font-size: 65%; } #fufjtblgnp .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;"> <colgroup> <col/> <col/> <col/> <col style="width:80px;"/> <col/> <col/> <col/> <col/> <col/> <col/> </colgroup> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0<sup class="gt_footnote_marks">1</sup></th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88<sup class="gt_footnote_marks">2</sup></td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="10">Quelle: eigene Erhebung.</td> </tr> <tr> <td class="gt_sourcenote" colspan="10">Anmerkungen: Mit <em>md()</em> können Textformatierungen vorgenommen <strong>werden</strong>.</td> </tr> </tfoot> <tfoot> <tr class="gt_footnotes"> <td colspan="10"> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>1</em> </sup> Ein Wert von <em>0</em> bedeutet <strong>keinerlei Studienmotivation</strong>. <br /> </p> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>2</em> </sup> <em><strong>Dies ist einfach nur ein Test.</strong></em> <br /> </p> </td> </tr> </tfoot> </table> </div> <p>Am häufigsten passt man die Breite aller Spalten an, damit die Tabelle gleichmäßig ist: Dies geschieht über die Funktion <code>everything()</code>:</p> <div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span></span> <span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)) <span class="sc">%>%</span> </span> <span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="sc">%>%</span> </span> <span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span></span> <span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="fu">md</span>(<span class="st">"Anmerkungen: Mit *md()* können Textformatierungen vorgenommen **werden**."</span>)) <span class="sc">%>%</span> </span> <span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"Ein Wert von *0* bedeutet **keinerlei Studienmotivation**."</span>),</span> <span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_column_labels</span>(<span class="at">columns =</span> <span class="st">"0"</span>)</span> <span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"***Dies ist einfach nur ein Test.***"</span>),</span> <span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_body</span>(<span class="at">columns =</span> <span class="dv">7</span>,</span> <span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a> <span class="at">rows =</span> <span class="dv">1</span></span> <span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb18-14"><a href="#cb18-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(<span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">45</span>))</span></code></pre></div> <div id="cncstrzpqs" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #cncstrzpqs .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #cncstrzpqs .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #cncstrzpqs .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #cncstrzpqs .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #cncstrzpqs .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #cncstrzpqs .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #cncstrzpqs .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #cncstrzpqs .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #cncstrzpqs .gt_column_spanner_outer:first-child { padding-left: 0; } #cncstrzpqs .gt_column_spanner_outer:last-child { padding-right: 0; } #cncstrzpqs .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #cncstrzpqs .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #cncstrzpqs .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #cncstrzpqs .gt_from_md > :first-child { margin-top: 0; } #cncstrzpqs .gt_from_md > :last-child { margin-bottom: 0; } #cncstrzpqs .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #cncstrzpqs .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #cncstrzpqs .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #cncstrzpqs .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #cncstrzpqs .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #cncstrzpqs .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #cncstrzpqs .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #cncstrzpqs .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #cncstrzpqs .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #cncstrzpqs .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #cncstrzpqs .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #cncstrzpqs .gt_sourcenote { font-size: 90%; padding: 4px; } #cncstrzpqs .gt_left { text-align: left; } #cncstrzpqs .gt_center { text-align: center; } #cncstrzpqs .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #cncstrzpqs .gt_font_normal { font-weight: normal; } #cncstrzpqs .gt_font_bold { font-weight: bold; } #cncstrzpqs .gt_font_italic { font-style: italic; } #cncstrzpqs .gt_super { font-size: 65%; } #cncstrzpqs .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0<sup class="gt_footnote_marks">1</sup></th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116</td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88<sup class="gt_footnote_marks">2</sup></td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="10">Quelle: eigene Erhebung.</td> </tr> <tr> <td class="gt_sourcenote" colspan="10">Anmerkungen: Mit <em>md()</em> können Textformatierungen vorgenommen <strong>werden</strong>.</td> </tr> </tfoot> <tfoot> <tr class="gt_footnotes"> <td colspan="10"> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>1</em> </sup> Ein Wert von <em>0</em> bedeutet <strong>keinerlei Studienmotivation</strong>. <br /> </p> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>2</em> </sup> <em><strong>Dies ist einfach nur ein Test.</strong></em> <br /> </p> </td> </tr> </tfoot> </table> </div> </div> <div id="schriftart-schriftgröße-ändern" class="section level2"> <h2>Schriftart & Schriftgröße ändern</h2> <p>Innerhalb von <code>tab_options()</code> gibt es eine Vielzahl von Optionen. Um Schriftarten zu ändern, muss man zuvor das <em>package</em> <code>extrafont</code> laden.</p> <div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"extrafont"</span>, </span> <span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a> <span class="at">dependencies =</span> <span class="cn">TRUE</span></span> <span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(<span class="st">"extrafont"</span>)</span> <span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a></span> <span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="co">#for mac</span></span> <span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a><span class="fu">loadfonts</span>(<span class="at">quiet =</span> <span class="cn">TRUE</span>)</span> <span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a></span> <span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a><span class="co"># for windows</span></span> <span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a><span class="fu">loadfonts</span>(<span class="at">device =</span> <span class="st">"pdf"</span>, <span class="co">#windows user use "win"</span></span> <span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a> <span class="at">quiet =</span> <span class="cn">TRUE</span></span> <span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a> )</span></code></pre></div> <p>So könnten wir die folgenden Anpassungen zum Beispiel vornehmen. Verändere den Code in der Funktion <code>tab_options()</code> einfach stellenweise, um zu sehen, was sich in der Darstellung ändert:</p> <div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>single <span class="sc">%>%</span></span> <span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Abs. Häufigkeit von Studienmotivation"</span>)) <span class="sc">%>%</span> </span> <span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="fu">c</span>(<span class="st">"center"</span>)) <span class="sc">%>%</span> </span> <span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span></span> <span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="fu">md</span>(<span class="st">"Anmerkungen: Mit *md()* können Textformatierungen vorgenommen **werden**."</span>)) <span class="sc">%>%</span> </span> <span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_footnote</span>(<span class="at">footnote =</span> <span class="fu">md</span>(<span class="st">"Ein Wert von *0* bedeutet **keinerlei Studienmotivation**"</span>),</span> <span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a> <span class="at">locations =</span> <span class="fu">cells_body</span>(<span class="at">columns =</span> <span class="fu">c</span>(<span class="dv">1</span>, </span> <span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a> <span class="dv">5</span></span> <span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a> ),</span> <span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a> <span class="at">rows =</span> <span class="dv">1</span></span> <span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(<span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">45</span>)) <span class="sc">%>%</span> </span> <span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_options</span>(<span class="at">table.font.names =</span> <span class="st">"Candara"</span>,</span> <span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a> <span class="at">table.font.size =</span> <span class="dv">12</span>,</span> <span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a> <span class="at">heading.title.font.size =</span> <span class="dv">14</span>,</span> <span id="cb20-17"><a href="#cb20-17" aria-hidden="true" tabindex="-1"></a> <span class="at">column_labels.font.size =</span> <span class="dv">13</span>,</span> <span id="cb20-18"><a href="#cb20-18" aria-hidden="true" tabindex="-1"></a> <span class="at">source_notes.font.size =</span> <span class="dv">9</span></span> <span id="cb20-19"><a href="#cb20-19" aria-hidden="true" tabindex="-1"></a> )</span></code></pre></div> <div id="ujutupzfwp" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: Candara; } #ujutupzfwp .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 12px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #ujutupzfwp .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ujutupzfwp .gt_title { color: #333333; font-size: 14px; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #ujutupzfwp .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #ujutupzfwp .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ujutupzfwp .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #ujutupzfwp .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 13px; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #ujutupzfwp .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 13px; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #ujutupzfwp .gt_column_spanner_outer:first-child { padding-left: 0; } #ujutupzfwp .gt_column_spanner_outer:last-child { padding-right: 0; } #ujutupzfwp .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #ujutupzfwp .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #ujutupzfwp .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #ujutupzfwp .gt_from_md > :first-child { margin-top: 0; } #ujutupzfwp .gt_from_md > :last-child { margin-bottom: 0; } #ujutupzfwp .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #ujutupzfwp .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #ujutupzfwp .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ujutupzfwp .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #ujutupzfwp .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #ujutupzfwp .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #ujutupzfwp .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #ujutupzfwp .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #ujutupzfwp .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ujutupzfwp .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #ujutupzfwp .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #ujutupzfwp .gt_sourcenote { font-size: 9px; padding: 4px; } #ujutupzfwp .gt_left { text-align: left; } #ujutupzfwp .gt_center { text-align: center; } #ujutupzfwp .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #ujutupzfwp .gt_font_normal { font-weight: normal; } #ujutupzfwp .gt_font_bold { font-weight: bold; } #ujutupzfwp .gt_font_italic { font-style: italic; } #ujutupzfwp .gt_super { font-size: 65%; } #ujutupzfwp .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> <col style="width:45px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="10" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Abs. Häufigkeit von Studienmotivation</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">0</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">1</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">2</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">3</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">4</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">5</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">6</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">7</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">8</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">9</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_center">105<sup class="gt_footnote_marks">1</sup></td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">81</td> <td class="gt_row gt_center">110</td> <td class="gt_row gt_center">116<sup class="gt_footnote_marks">1</sup></td> <td class="gt_row gt_center">93</td> <td class="gt_row gt_center">88</td> <td class="gt_row gt_center">108</td> <td class="gt_row gt_center">91</td> <td class="gt_row gt_center">115</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="10">Quelle: eigene Erhebung.</td> </tr> <tr> <td class="gt_sourcenote" colspan="10">Anmerkungen: Mit <em>md()</em> können Textformatierungen vorgenommen <strong>werden</strong>.</td> </tr> </tfoot> <tfoot> <tr class="gt_footnotes"> <td colspan="10"> <p class="gt_footnote"> <sup class="gt_footnote_marks"> <em>1</em> </sup> Ein Wert von <em>0</em> bedeutet <strong>keinerlei Studienmotivation</strong> <br /> </p> </td> </tr> </tfoot> </table> </div> <p>Dies stellt nur einen Ausschnitt der Funktionsmöglichkeiten von <code>gt</code> dar. Es können auch einzelne Zellen spezifisch farbig gestaltet werden und auch nach einer weiteren Variable dargestellt werden. Dazu ist ein Blick in die <a href="https://gt.rstudio.com/">Benutzerdokumentation</a> hilfreich.</p> </div> <div id="anpassungen-bei-kreuztabellen" class="section level2"> <h2>Anpassungen bei Kreuztabellen</h2> <p>Nun wollen wir abschließend noch die Kreuztablle anpassen. Wir übernehmen die oben eingeführten Anpassungen für den Title, die Spaltenbreite und die Quelle. Die erste Spalte machen wir nun aber breiter als die anderen. Auch richten wir die erste Spalte links aus (wie nach Konvention üblich).</p> <div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>cross <span class="sc">%>%</span> </span> <span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Studienort & Studienwahl"</span>)) <span class="sc">%>%</span> </span> <span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"left"</span>,</span> <span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> study</span> <span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"center"</span>,</span> <span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> <span class="fu">c</span>(<span class="st">"Gießen"</span>, </span> <span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a> <span class="st">"Marburg"</span>,</span> <span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"Frankfurt"</span></span> <span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb21-11"><a href="#cb21-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb21-12"><a href="#cb21-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span> </span> <span id="cb21-13"><a href="#cb21-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(study <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">150</span>),</span> <span id="cb21-14"><a href="#cb21-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">100</span>)</span> <span id="cb21-15"><a href="#cb21-15" aria-hidden="true" tabindex="-1"></a> ) </span></code></pre></div> <div id="wltrbyhvef" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #wltrbyhvef .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #wltrbyhvef .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #wltrbyhvef .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #wltrbyhvef .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #wltrbyhvef .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #wltrbyhvef .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #wltrbyhvef .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #wltrbyhvef .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #wltrbyhvef .gt_column_spanner_outer:first-child { padding-left: 0; } #wltrbyhvef .gt_column_spanner_outer:last-child { padding-right: 0; } #wltrbyhvef .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #wltrbyhvef .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #wltrbyhvef .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #wltrbyhvef .gt_from_md > :first-child { margin-top: 0; } #wltrbyhvef .gt_from_md > :last-child { margin-bottom: 0; } #wltrbyhvef .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #wltrbyhvef .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #wltrbyhvef .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #wltrbyhvef .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #wltrbyhvef .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #wltrbyhvef .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #wltrbyhvef .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #wltrbyhvef .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #wltrbyhvef .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #wltrbyhvef .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #wltrbyhvef .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #wltrbyhvef .gt_sourcenote { font-size: 90%; padding: 4px; } #wltrbyhvef .gt_left { text-align: left; } #wltrbyhvef .gt_center { text-align: center; } #wltrbyhvef .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #wltrbyhvef .gt_font_normal { font-weight: normal; } #wltrbyhvef .gt_font_bold { font-weight: bold; } #wltrbyhvef .gt_font_italic { font-style: italic; } #wltrbyhvef .gt_super { font-size: 65%; } #wltrbyhvef .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:150px;"/> <col style="width:100px;"/> <col style="width:100px;"/> <col style="width:100px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="4" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Studienort & Studienwahl</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1">study</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_left">Political Science</td> <td class="gt_row gt_center">0.2071006</td> <td class="gt_row gt_center">0.2057143</td> <td class="gt_row gt_center">0.2500000</td></tr> <tr><td class="gt_row gt_left">Sociology</td> <td class="gt_row gt_center">0.2603550</td> <td class="gt_row gt_center">0.2685714</td> <td class="gt_row gt_center">0.2596154</td></tr> <tr><td class="gt_row gt_left">Educational Science</td> <td class="gt_row gt_center">0.2810651</td> <td class="gt_row gt_center">0.2742857</td> <td class="gt_row gt_center">0.2371795</td></tr> <tr><td class="gt_row gt_left">Psychology</td> <td class="gt_row gt_center">0.2514793</td> <td class="gt_row gt_center">0.2514286</td> <td class="gt_row gt_center">0.2532051</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="4">Quelle: eigene Erhebung.</td> </tr> </tfoot> </table> </div> <p>Was wir an dieser Stelle noch anpassen wollen, ist das die Zellen jeweils auf zwei Nachkommastellen gerundet werden. Dazu nutzen wir <code>fmt()</code>. Mit dem Argument <code>columns</code> bestimmen wir in welchen Zeilen gerundet werden soll, mit dem Argument <code>decimals</code> legen wir die Dezimalstellen fest und wer das Dezimalzeichen ändern möchte, kann dies im Argument <code>dec_mark</code> machen (dann auch <code>sep_mark</code> (Tausenderzeichen) ändern:</p> <div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>cross <span class="sc">%>%</span> </span> <span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Studienort & Studienwahl"</span>)) <span class="sc">%>%</span> </span> <span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"left"</span>,</span> <span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> study</span> <span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"center"</span>,</span> <span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> <span class="fu">c</span>(<span class="st">"Gießen"</span>, </span> <span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a> <span class="st">"Marburg"</span>,</span> <span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"Frankfurt"</span></span> <span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb22-11"><a href="#cb22-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb22-12"><a href="#cb22-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span> </span> <span id="cb22-13"><a href="#cb22-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(study <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">150</span>),</span> <span id="cb22-14"><a href="#cb22-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">100</span>)</span> <span id="cb22-15"><a href="#cb22-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb22-16"><a href="#cb22-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">fmt_number</span>(<span class="at">columns =</span> <span class="fu">c</span>(<span class="dv">2</span><span class="sc">:</span><span class="dv">4</span>), </span> <span id="cb22-17"><a href="#cb22-17" aria-hidden="true" tabindex="-1"></a> <span class="at">decimals =</span> <span class="dv">2</span>,</span> <span id="cb22-18"><a href="#cb22-18" aria-hidden="true" tabindex="-1"></a> <span class="at">dec_mark =</span> <span class="st">","</span>,</span> <span id="cb22-19"><a href="#cb22-19" aria-hidden="true" tabindex="-1"></a> <span class="at">sep_mark =</span> <span class="st">"."</span></span> <span id="cb22-20"><a href="#cb22-20" aria-hidden="true" tabindex="-1"></a> )</span></code></pre></div> <div id="lrhjonejen" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #lrhjonejen .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #lrhjonejen .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #lrhjonejen .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #lrhjonejen .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #lrhjonejen .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #lrhjonejen .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #lrhjonejen .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #lrhjonejen .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #lrhjonejen .gt_column_spanner_outer:first-child { padding-left: 0; } #lrhjonejen .gt_column_spanner_outer:last-child { padding-right: 0; } #lrhjonejen .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #lrhjonejen .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #lrhjonejen .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #lrhjonejen .gt_from_md > :first-child { margin-top: 0; } #lrhjonejen .gt_from_md > :last-child { margin-bottom: 0; } #lrhjonejen .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #lrhjonejen .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #lrhjonejen .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #lrhjonejen .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #lrhjonejen .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #lrhjonejen .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #lrhjonejen .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #lrhjonejen .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #lrhjonejen .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #lrhjonejen .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #lrhjonejen .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #lrhjonejen .gt_sourcenote { font-size: 90%; padding: 4px; } #lrhjonejen .gt_left { text-align: left; } #lrhjonejen .gt_center { text-align: center; } #lrhjonejen .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #lrhjonejen .gt_font_normal { font-weight: normal; } #lrhjonejen .gt_font_bold { font-weight: bold; } #lrhjonejen .gt_font_italic { font-style: italic; } #lrhjonejen .gt_super { font-size: 65%; } #lrhjonejen .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:150px;"/> <col style="width:100px;"/> <col style="width:100px;"/> <col style="width:100px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="4" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Studienort & Studienwahl</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1">study</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_left">Political Science</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,25</td></tr> <tr><td class="gt_row gt_left">Sociology</td> <td class="gt_row gt_center">0,26</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,26</td></tr> <tr><td class="gt_row gt_left">Educational Science</td> <td class="gt_row gt_center">0,28</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,24</td></tr> <tr><td class="gt_row gt_left">Psychology</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="4">Quelle: eigene Erhebung.</td> </tr> </tfoot> </table> </div> <p>Bevor wir die Einführung ändern möchten wir noch den <em>Header</em> in der ersten Spalte ändern. Dies können wir über <code>cols_label()</code>:</p> <div class="sourceCode" id="cb23"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a>cross <span class="sc">%>%</span> </span> <span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Studienort & Studienwahl"</span>)) <span class="sc">%>%</span> </span> <span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"left"</span>,</span> <span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> study</span> <span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"center"</span>,</span> <span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> <span class="fu">c</span>(<span class="st">"Gießen"</span>, </span> <span id="cb23-8"><a href="#cb23-8" aria-hidden="true" tabindex="-1"></a> <span class="st">"Marburg"</span>,</span> <span id="cb23-9"><a href="#cb23-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"Frankfurt"</span></span> <span id="cb23-10"><a href="#cb23-10" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb23-11"><a href="#cb23-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb23-12"><a href="#cb23-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span> </span> <span id="cb23-13"><a href="#cb23-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(study <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">150</span>),</span> <span id="cb23-14"><a href="#cb23-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">100</span>)</span> <span id="cb23-15"><a href="#cb23-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb23-16"><a href="#cb23-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">fmt_number</span>(<span class="at">columns =</span> <span class="fu">c</span>(<span class="dv">2</span><span class="sc">:</span><span class="dv">4</span>), </span> <span id="cb23-17"><a href="#cb23-17" aria-hidden="true" tabindex="-1"></a> <span class="at">decimals =</span> <span class="dv">2</span>,</span> <span id="cb23-18"><a href="#cb23-18" aria-hidden="true" tabindex="-1"></a> <span class="at">dec_mark =</span> <span class="st">","</span>,</span> <span id="cb23-19"><a href="#cb23-19" aria-hidden="true" tabindex="-1"></a> <span class="at">sep_mark =</span> <span class="st">"."</span></span> <span id="cb23-20"><a href="#cb23-20" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb23-21"><a href="#cb23-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_label</span>(<span class="at">study =</span> <span class="st">"Studienfach"</span>)</span></code></pre></div> <div id="cccyrnjfrv" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #cccyrnjfrv .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #cccyrnjfrv .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #cccyrnjfrv .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #cccyrnjfrv .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #cccyrnjfrv .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #cccyrnjfrv .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #cccyrnjfrv .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #cccyrnjfrv .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #cccyrnjfrv .gt_column_spanner_outer:first-child { padding-left: 0; } #cccyrnjfrv .gt_column_spanner_outer:last-child { padding-right: 0; } #cccyrnjfrv .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #cccyrnjfrv .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #cccyrnjfrv .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #cccyrnjfrv .gt_from_md > :first-child { margin-top: 0; } #cccyrnjfrv .gt_from_md > :last-child { margin-bottom: 0; } #cccyrnjfrv .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #cccyrnjfrv .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #cccyrnjfrv .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #cccyrnjfrv .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #cccyrnjfrv .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #cccyrnjfrv .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #cccyrnjfrv .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #cccyrnjfrv .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #cccyrnjfrv .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #cccyrnjfrv .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #cccyrnjfrv .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #cccyrnjfrv .gt_sourcenote { font-size: 90%; padding: 4px; } #cccyrnjfrv .gt_left { text-align: left; } #cccyrnjfrv .gt_center { text-align: center; } #cccyrnjfrv .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #cccyrnjfrv .gt_font_normal { font-weight: normal; } #cccyrnjfrv .gt_font_bold { font-weight: bold; } #cccyrnjfrv .gt_font_italic { font-style: italic; } #cccyrnjfrv .gt_super { font-size: 65%; } #cccyrnjfrv .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:150px;"/> <col style="width:100px;"/> <col style="width:100px;"/> <col style="width:100px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="4" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Studienort & Studienwahl</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1">Studienfach</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_left">Political Science</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,25</td></tr> <tr><td class="gt_row gt_left">Sociology</td> <td class="gt_row gt_center">0,26</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,26</td></tr> <tr><td class="gt_row gt_left">Educational Science</td> <td class="gt_row gt_center">0,28</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,24</td></tr> <tr><td class="gt_row gt_left">Psychology</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="4">Quelle: eigene Erhebung.</td> </tr> </tfoot> </table> </div> <p>Auch dabei können mit <code>md()</code> Formatierungen vorgenommen werden:</p> <div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a>cross <span class="sc">%>%</span> </span> <span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Studienort & Studienwahl"</span>)) <span class="sc">%>%</span> </span> <span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"left"</span>,</span> <span id="cb24-4"><a href="#cb24-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> study</span> <span id="cb24-5"><a href="#cb24-5" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb24-6"><a href="#cb24-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"center"</span>,</span> <span id="cb24-7"><a href="#cb24-7" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> <span class="fu">c</span>(<span class="st">"Gießen"</span>, </span> <span id="cb24-8"><a href="#cb24-8" aria-hidden="true" tabindex="-1"></a> <span class="st">"Marburg"</span>,</span> <span id="cb24-9"><a href="#cb24-9" aria-hidden="true" tabindex="-1"></a> <span class="st">"Frankfurt"</span></span> <span id="cb24-10"><a href="#cb24-10" aria-hidden="true" tabindex="-1"></a> )</span> <span id="cb24-11"><a href="#cb24-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb24-12"><a href="#cb24-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span> </span> <span id="cb24-13"><a href="#cb24-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(study <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">150</span>),</span> <span id="cb24-14"><a href="#cb24-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">100</span>)</span> <span id="cb24-15"><a href="#cb24-15" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb24-16"><a href="#cb24-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">fmt_number</span>(<span class="at">columns =</span> <span class="fu">c</span>(<span class="dv">2</span><span class="sc">:</span><span class="dv">4</span>), </span> <span id="cb24-17"><a href="#cb24-17" aria-hidden="true" tabindex="-1"></a> <span class="at">decimals =</span> <span class="dv">2</span>,</span> <span id="cb24-18"><a href="#cb24-18" aria-hidden="true" tabindex="-1"></a> <span class="at">dec_mark =</span> <span class="st">","</span>,</span> <span id="cb24-19"><a href="#cb24-19" aria-hidden="true" tabindex="-1"></a> <span class="at">sep_mark =</span> <span class="st">"."</span></span> <span id="cb24-20"><a href="#cb24-20" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb24-21"><a href="#cb24-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_label</span>(<span class="at">study =</span> <span class="fu">md</span>(<span class="st">"**Studien-**<br>*fach*"</span>))</span></code></pre></div> <div id="eimvudjzzc" style="overflow-x:auto;overflow-y:auto;width:auto;height:auto;"> <style>html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif; } #eimvudjzzc .gt_table { display: table; border-collapse: collapse; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; } #eimvudjzzc .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #eimvudjzzc .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; border-bottom-color: #FFFFFF; border-bottom-width: 0; } #eimvudjzzc .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 0; padding-bottom: 6px; border-top-color: #FFFFFF; border-top-width: 0; } #eimvudjzzc .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #eimvudjzzc .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; } #eimvudjzzc .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 6px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; } #eimvudjzzc .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; } #eimvudjzzc .gt_column_spanner_outer:first-child { padding-left: 0; } #eimvudjzzc .gt_column_spanner_outer:last-child { padding-right: 0; } #eimvudjzzc .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; } #eimvudjzzc .gt_group_heading { padding: 8px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; } #eimvudjzzc .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; } #eimvudjzzc .gt_from_md > :first-child { margin-top: 0; } #eimvudjzzc .gt_from_md > :last-child { margin-bottom: 0; } #eimvudjzzc .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; } #eimvudjzzc .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 12px; } #eimvudjzzc .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #eimvudjzzc .gt_first_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; } #eimvudjzzc .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; } #eimvudjzzc .gt_first_grand_summary_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; } #eimvudjzzc .gt_striped { background-color: rgba(128, 128, 128, 0.05); } #eimvudjzzc .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; } #eimvudjzzc .gt_footnotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #eimvudjzzc .gt_footnote { margin: 0px; font-size: 90%; padding: 4px; } #eimvudjzzc .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; } #eimvudjzzc .gt_sourcenote { font-size: 90%; padding: 4px; } #eimvudjzzc .gt_left { text-align: left; } #eimvudjzzc .gt_center { text-align: center; } #eimvudjzzc .gt_right { text-align: right; font-variant-numeric: tabular-nums; } #eimvudjzzc .gt_font_normal { font-weight: normal; } #eimvudjzzc .gt_font_bold { font-weight: bold; } #eimvudjzzc .gt_font_italic { font-style: italic; } #eimvudjzzc .gt_super { font-size: 65%; } #eimvudjzzc .gt_footnote_marks { font-style: italic; font-weight: normal; font-size: 65%; } </style> <table class="gt_table" style="table-layout: fixed;; width: 0px"> <colgroup> <col style="width:150px;"/> <col style="width:100px;"/> <col style="width:100px;"/> <col style="width:100px;"/> </colgroup> <thead class="gt_header"> <tr> <th colspan="4" class="gt_heading gt_title gt_font_normal gt_bottom_border" style>Studienort & Studienwahl</th> </tr> </thead> <thead class="gt_col_headings"> <tr> <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1"><strong>Studien-</strong><br><em>fach</em></th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Gießen</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Marburg</th> <th class="gt_col_heading gt_columns_bottom_border gt_center" rowspan="1" colspan="1">Frankfurt</th> </tr> </thead> <tbody class="gt_table_body"> <tr><td class="gt_row gt_left">Political Science</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,21</td> <td class="gt_row gt_center">0,25</td></tr> <tr><td class="gt_row gt_left">Sociology</td> <td class="gt_row gt_center">0,26</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,26</td></tr> <tr><td class="gt_row gt_left">Educational Science</td> <td class="gt_row gt_center">0,28</td> <td class="gt_row gt_center">0,27</td> <td class="gt_row gt_center">0,24</td></tr> <tr><td class="gt_row gt_left">Psychology</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td> <td class="gt_row gt_center">0,25</td></tr> </tbody> <tfoot class="gt_sourcenotes"> <tr> <td class="gt_sourcenote" colspan="4">Quelle: eigene Erhebung.</td> </tr> </tfoot> </table> </div> <p>So, für die Einführung in das <em>package</em> <code>gt</code> ist dies ausreichend. Insbesondere, wenn man eine dritte Gruppenvariable hinzufügt, bietet <code>gt</code> gute Möglichkeiten direkt in R publizierbare Tabellen zu generieren.</p> </div> <div id="bevor-ihr-geht-speichert" class="section level2"> <h2>Bevor ihr geht, speichert!</h2> <p>Anstatt aus dem Viewer die Dateien zu speichern, kann man diese auch direkt über <code>gtsave()</code> speichern. Dazu gibt man einfach den Dateinamen ein und R speichert das Objekt im <em>Working Directory</em>.</p> <div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a>cross <span class="sc">%>%</span> </span> <span id="cb25-2"><a href="#cb25-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_header</span>(<span class="at">title =</span> <span class="fu">md</span>(<span class="st">"Studienort & Studienwahl"</span>)) <span class="sc">%>%</span> </span> <span id="cb25-3"><a href="#cb25-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"left"</span>,</span> <span id="cb25-4"><a href="#cb25-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> study</span> <span id="cb25-5"><a href="#cb25-5" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb25-6"><a href="#cb25-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_align</span>(<span class="at">align =</span> <span class="st">"center"</span>,</span> <span id="cb25-7"><a href="#cb25-7" aria-hidden="true" tabindex="-1"></a> <span class="at">columns =</span> <span class="fu">c</span>(<span class="st">"Gießen"</span>, <span class="st">"Marburg"</span>, <span class="st">'Frankfurt'</span>)) <span class="sc">%>%</span> </span> <span id="cb25-8"><a href="#cb25-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">tab_source_note</span>(<span class="at">source_note =</span> <span class="st">"Quelle: eigene Erhebung."</span>) <span class="sc">%>%</span> </span> <span id="cb25-9"><a href="#cb25-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_width</span>(study <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">150</span>),</span> <span id="cb25-10"><a href="#cb25-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">everything</span>() <span class="sc">~</span> <span class="fu">px</span>(<span class="dv">100</span>)</span> <span id="cb25-11"><a href="#cb25-11" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb25-12"><a href="#cb25-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">fmt_number</span>(<span class="at">columns =</span> <span class="fu">c</span>(<span class="dv">2</span><span class="sc">:</span><span class="dv">4</span>), </span> <span id="cb25-13"><a href="#cb25-13" aria-hidden="true" tabindex="-1"></a> <span class="at">decimals =</span> <span class="dv">2</span></span> <span id="cb25-14"><a href="#cb25-14" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">%>%</span> </span> <span id="cb25-15"><a href="#cb25-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">cols_label</span>(<span class="at">study =</span> <span class="fu">md</span>(<span class="st">"**Studien-**<br>*fach*"</span>)) <span class="sc">%>%</span> </span> <span id="cb25-16"><a href="#cb25-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">gtsave</span>(<span class="st">"mein-erster-gt-plot.png"</span>) <span class="co"># auch .html -Table möglich</span></span></code></pre></div> <p><img src="pics/s6-gt-crosstable-save-1.png" width="288" style="display: block; margin: auto;" /></p> <div id="das-wars" class="section level3"> <h3>Das war’s!</h3> <p>Die Labs findet ihr auch in der Cloud.</p> <p>Ihr sehr hier drei verschiedene Tabellendarstellungen. Sucht euch eine Tabellendarstellung heraus und stellt diese mithilfe des <code>gt</code>-<em>package</em> nach.</p> <div class="figure"> <img src="pics/gt-task1.png" alt="" /> <p class="caption">gt Task 1</p> </div> <div class="figure"> <img src="pics/gt-task2.png" alt="" /> <p class="caption">gt Task 2</p> </div> <div class="figure"> <img src="pics/gt-task3.png" alt="" /> <p class="caption">gt Task 3</p> </div> </div> </div> <br><br> <hr /> <center> <p style="font-size:10px"> Copyright: <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a> <br/>Benedikt Philipp Kleer, Justus-Liebig-Universität Gießen. </p> </center> </div> </div> </div> <script> // add bootstrap table styles to pandoc tables function bootstrapStylePandocTables() { $('tr.odd').parent('tbody').parent('table').addClass('table table-condensed'); } $(document).ready(function () { bootstrapStylePandocTables(); }); </script> <!-- tabsets --> <script> $(document).ready(function () { window.buildTabsets("TOC"); }); $(document).ready(function () { $('.tabset-dropdown > .nav-tabs > li').click(function () { $(this).parent().toggleClass('nav-tabs-open'); }); }); </script> <!-- code folding --> <script> $(document).ready(function () { // temporarily add toc-ignore selector to headers for the consistency with Pandoc $('.unlisted.unnumbered').addClass('toc-ignore') // move toc-ignore selectors from section div to header $('div.section.toc-ignore') .removeClass('toc-ignore') .children('h1,h2,h3,h4,h5').addClass('toc-ignore'); // establish options var options = { selectors: "h1,h2,h3", theme: "bootstrap3", context: '.toc-content', hashGenerator: function (text) { return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_'); }, ignoreSelector: ".toc-ignore", scrollTo: 0 }; options.showAndHide = true; options.smoothScroll = true; // tocify var toc = $("#TOC").tocify(options).data("toc-tocify"); }); </script> <!-- dynamically load mathjax for compatibility with self-contained --> <script> (function () { var script = document.createElement("script"); script.type = "text/javascript"; script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; document.getElementsByTagName("head")[0].appendChild(script); })(); </script> </body> </html>