<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>r &amp;mdash; bs2facdev</title>
    <link>https://write.as/bs2facdev/tag:r</link>
    <description></description>
    <pubDate>Mon, 24 Aug 2026 12:34:53 +0000</pubDate>
    <item>
      <title>アンケート Questionnaire Visualization with R ggplot2</title>
      <link>https://write.as/bs2facdev/anketo-questionnaire-visualization-with-r-ggplot2?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[FDアンケート結果の視覚化への挑戦 1。フリーソフトのエディターEmacs, orgmodeとフリーな言語R, ggplot2と遊びながら、情報デザインを考える機会です。&#xA;Faculty Development questionnaire results give me a chance to re-visit Edward Tufte&#39;s Beautiful Evidence and attempt to implement his design ideas with emacs, org-mode and R, ggplot2.&#xA;&#xA;Emacs org-modeの表には無駄なインクがありません。 簡単に生成するテーブル(表)は木下是雄さんの「レポートの組み立て方 」で見る表に負けなません、 すっきりしている。&#xA;The html pages exported by org-mode have a high ink-to-data ratio. They remind me of a book about writing for scientists. (fn:1)&#xA;&#xA;色々なデータ表をブラウザーで一目(one eye-span)で見ることができる。まとめて見えるようにするのが一つの原則(Principle).&#xA;The browser lets us see several data tables within one eye-span. Orgmode-generated html with some .css styling can implement Edward Tufte&#39;s design principle: &#34;one eye-span.&#34;&#xA;&#xA;!--more--&#xA;Emacでデータ入力するときは見た目は違う。&#xA;In emacs the tables have a different appearance.&#xA;&#xA;Emacs org-mode and R ggplot2 code&#xA;It&#39;s awkward but it works. It may help to get started thinking about Reproducible Research. (fn:2)&#xA;エレガントなコードではないけど、動く。&#xA;+TITLE: Combined Views 教員, 学科, 大学&#xA;+STARTUP: showall&#xA;+OPTIONS: toc:nil num:nil timestamp:nil ^:{} H:4&#xA;&#xA;+HTMLHEAD: style @page { size: 210mm 297mm; margin: 4mm; margin-bottom: 6mm; } /style&#xA;+HTMLHEAD: style h1.title { display: none; }  /style&#xA;+HTMLHEAD: style h1, h2, h3, h4 { font-weight: 500; font-size: 1.2em; clear: left;}  /style&#xA;#+HTMLHEAD: style div#postamble { display: none; }  /style&#xA;&#xA;# # doesn&#39;t clear the following tables&#xA;#+HTMLHEAD: style div#outline-container-SetumonJouhou { clear: right; }  /style&#xA;#+HTMLHEAD: style div#outline-container-DataJouhou { clear: right; }  /style&#xA;# #+HTMLHEAD: style div#outline-container-KekkaJouhou { clear: right; }/style&#xA;&#xA; &#xA;+HTMLHEAD: style h3 { clear: left; display: none; }  /style&#xA;+HTMLHEAD: style div.outline-3 { clear: left; }  /style&#xA;# #+HTMLHEAD: style #outline-container-KekkaJouhou { clear: left; }  /style&#xA;&#xA;+HTMLHEAD: style table {margin-bottom: 1em; margin-right: 1em; float: left; page-break-inside: avoid;}  /style&#xA;+HTMLHEAD: style span.table-number { display: none; }  /style&#xA;+HTMLHEAD: style span.figure-number { display: none; }  /style&#xA;+HTMLHEAD: style td { padding: 3px; }   /style&#xA;&#xA;#+HTMLHEAD: style table#QuestionTypes { float: left; }  /style&#xA;#+HTMLHEAD: style table#ResponseTypes { margin: 1em; clear: right; }  /style&#xA;&#xA;#+HTMLHEAD: style table#InfoDG { float: left; } /style&#xA;#+HTMLHEAD: style table#InfoGK { float: left; }  /style&#xA;#+HTMLHEAD: style table#InfoKI { float: left; clear: right }  /style&#xA;&#xA;#+HTMLHEAD: style table#FreqDG { float: left; } /style&#xA;#+HTMLHEAD: style table#FreqsGK { float: left; }  /style&#xA;#+HTMLHEAD: style table#FreqKI { float: left; clear: right }  /style&#xA;&#xA;#+HTMLHEAD: style table#QuestionsAsVariables td { font-size: 10pt; }  /style&#xA;&#xA;#+HTMLHEAD: style table#TidyDataOuput td { font-size: 10pt; }  /style&#xA;&#xA;#+HTMLHEAD: style div#outline-container-TidyData { clear: left; page-break-before: always; }  /style&#xA;&#xA;+HTMLHEAD: style pre.src, pre.example { border: none; margin: .5em;  box-shadow: none; padding: 0; }  /style&#xA;+HTMLHEAD: style pre.example { margin-left: 4em; padding-left: 1em; border-left: thin solid grey; }  /style&#xA;&#xA;#+HTMLHEAD: style div#outline-container-Data h2 { display: none; }  /style&#xA;&#xA;+HTMLHEAD: style div.org-src-container { clear: left; }  /style&#xA;# #+HTMLHEAD: style img { width: 100%; }  /style&#xA;adjust width of image to fit on pages under frequency data tables&#xA;+HTMLHEAD: style img { width: 700px; } /style&#xA;&#xA;設問情報&#xA;:PROPERTIES:&#xA;:CUSTOMID: SetsumonJouhou&#xA;:END:&#xA;&#xA; 質問&#xA;+CAPTION: Questions&#xA;+name: Questions&#xA;| 種略     | 問略 | 問文                                                                  |&#xA;|----------+------+-----------------------------------------------------------------------|&#xA;| 学生取組 | 出席 | 私はこの授業によく出席した                                            |&#xA;| 学生取組 | 発言 | 私は授業内容について質問や発言した                                    |&#xA;| 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した）                    |&#xA;| 教員実施 | 聞取 | 教員の声は聞き取りやすかった。                                        |&#xA;| 教員実施 | 資料 | 教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった） |&#xA;| 教員実施 | 時刻 | 教員は授業の開始・終了の時刻を守ろうとしていた                        |&#xA;| 教員実施 | 反応 | 教員は学生の反応を確かめながら授業を進めていた                        |&#xA;| 教員実施 | 熱意 | 教員は熱意を持って授業をしていた                                      |&#xA;| 総合評価 | 理解 | 私はこの授業内容を理解できた                                          |&#xA;| 総合評価 | 役立 | 私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた        |&#xA;| 総合評価 | 満足 | 私は総合的に判断してこの授業で満足が得られた                          |&#xA;&#xA; 質問と回答の分類&#xA;+CAPTION: Question Types&#xA;+name: QuestionTypes&#xA;| 種略     | 種文                           |&#xA;|----------+--------------------------------|&#xA;| 学生取組 | 学生の授業取り組みに関する質問 |&#xA;| 教員実施 | 教員の授業実施方法に関する質問 |&#xA;| 総合評価 | 総合的評価に関する質問         |&#xA;&#xA;+CAPTION: Response Types&#xA;+name: ResponseTypes&#xA;| 答種 | L | 答略   | 答文               |&#xA;|------+---+--------+--------------------|&#xA;| SO   | 5 | 特に   | 特にそう思う       |&#xA;| SO   | 4 | 多少   | 多少そう思う       |&#xA;| DO   | 3 | どちも | どちらともいえない |&#xA;| NO   | 2 | あまり | あまりそう思わない |&#xA;| NO   | 1 | 全く   | 全くそう思わない   |&#xA;&#xA;データ情報&#xA;:PROPERTIES:&#xA;:CUSTOMID: DataJouhou&#xA;:END:&#xA;&#xA; 情報の表&#xA;:PROPERTIES:&#xA;:CUSTOMID: InfoTables&#xA;:END:&#xA;&#xA;+CAPTION: 学年、学期&#xA;+name: Year-Semester&#xA;| 学年 | 学期 |&#xA;|------+------|&#xA;| 2018 |    2 |&#xA;&#xA;+CAPTION: 体とコード&#xA;+name: Tai-Kanji-CD&#xA;| 体           | 体種 | CD |&#xA;|--------------+------+----|&#xA;| 南九州大学   | 大学 | DG |&#xA;| 教養センター | 学科 | GK |&#xA;| 教職員       | 教員 | KI |&#xA;&#xA; 大学、学科、教員の情報&#xA;:PROPERTIES:&#xA;:CUSTOMID: EntityDataJouhou&#xA;:END:&#xA;+CAPTION: 大学の情報&#xA;+name: InfoDG&#xA;| 体   | 員 |   枚 |&#xA;|------+----+------|&#xA;| 大学 | 57 | 2403 |&#xA;&#xA;+CAPTION: 学科の情報&#xA;+name: InfoGK&#xA;| 体   | 員 |  枚 |&#xA;|------+----+-----|&#xA;| 学科 |  6 | 276 |&#xA;&#xA;+CAPTION: 教員の情報&#xA;+name: InfoKI&#xA;| 体   | 員 | 枚 |&#xA;|------+----+----|&#xA;| 教員 |  1 | 68 |&#xA;&#xA; 結果情報&#xA;:PROPERTIES:&#xA;:CUSTOMID: KekkaJouhou&#xA;:END:&#xA;+CAPTION: 教員の結果&#xA;+name: FreqKI&#xA;|  5 |  4 |  3 |  2 | 1 |&#xA;|----+----+----+----+---|&#xA;| 33 | 28 |  6 |  1 | 0 |&#xA;|  8 | 27 | 19 |  9 | 5 |&#xA;|  8 | 25 | 22 | 12 | 1 |&#xA;| 37 | 25 |  6 |  0 | 0 |&#xA;| 21 | 34 | 11 |  2 | 0 |&#xA;| 49 | 16 |  3 |  0 | 0 |&#xA;| 47 | 16 |  5 |  0 | 0 |&#xA;| 56 | 11 |  1 |  0 | 0 |&#xA;| 25 | 31 |  7 |  5 | 0 |&#xA;| 17 | 33 | 15 |  2 | 1 |&#xA;| 19 | 38 |  8 |  2 | 1 |&#xA;&#xA;+CAPTION: 学科の結果&#xA;+name: FreqGK&#xA;|   5 |   4 |   3 |  2 |  1 |&#xA;|-----+-----+-----+----+----|&#xA;| 198 |  59 |  16 |  3 |  0 |&#xA;|  39 |  86 | 102 | 26 | 22 |&#xA;|  50 |  96 |  90 | 29 |  9 |&#xA;| 130 |  91 |  40 | 10 |  4 |&#xA;|  98 | 107 |  55 | 12 |  3 |&#xA;| 174 |  70 |  26 |  4 |  2 |&#xA;| 125 |  95 |  48 |  5 |  3 |&#xA;| 161 |  81 |  30 |  2 |  1 |&#xA;|  99 | 114 |  45 | 13 |  5 |&#xA;|  95 | 105 |  65 |  8 |  3 |&#xA;|  89 | 120 |  51 |  9 |  7 |&#xA;&#xA;+CAPTION: 大学の結果&#xA;+name: FreqDG&#xA;|    5 |   4 |   3 |   2 |   1 |&#xA;|------+-----+-----+-----+-----|&#xA;| 1689 | 479 | 202 |  31 |  10 |&#xA;|  419 | 616 | 974 | 190 | 199 |&#xA;|  684 | 822 | 692 | 134 |  65 |&#xA;| 1341 | 670 | 293 |  69 |  28 |&#xA;| 1200 | 695 | 374 |  86 |  42 |&#xA;| 1702 | 480 | 169 |  28 |  17 |&#xA;| 1315 | 652 | 349 |  52 |  33 |&#xA;| 1537 | 585 | 236 |  21 |  19 |&#xA;|  938 | 940 | 412 |  73 |  34 |&#xA;| 1328 | 676 | 325 |  43 |  26 |&#xA;| 1172 | 781 | 356 |  55 |  34 |&#xA;&#xA; データ視覚化の画像&#xA;+RESULTS: WariQTypeFacets&#xA;[[file:KIGKDGFacets-H30K.png]]&#xA;&#xA;Code for Image: Data Visualization&#xA;:PROPERTIES:&#xA;:CUSTOMID: Images-Data-Visualizations&#xA;:END:&#xA;&#xA;+name: evaluate-now&#xA;+BEGINSRC emacs-lisp&#xA;(setq org-confirm-babel-evaluate nil)&#xA;+ENDSRC&#xA;&#xA;+RESULTS: evaluate-now&#xA;&#xA;+name: R-Libraries&#xA;+BEGINSRC R  :session Rinddepuni :results silent&#xA;library(tidyverse)&#xA;library(stringr)&#xA;library(ggrepel)&#xA;library(forcats)&#xA;+ENDSRC&#xA;&#xA;+name: Convenience-Functions&#xA;+BEGINSRC R  :session Rinddepuni&#xA;# # Maintain order of data from original tables&#xA;FctOrd &lt;- function(col) {&#xA;  col &lt;- factor(col, levels=unique(col))&#xA;  }&#xA;&#xA;Remove Part from Group&#xA;# # Minus Prt$5 4 3 2 1 from Grp$5&#xA;RemPRT &lt;- function(Grp, Prt) {&#xA;  nGRP &lt;- Grp&#xA;  nGRP$X5 &lt;- Grp$X5 - Prt$X5&#xA;  nGRP$X4 &lt;- Grp$X4 - Prt$X4&#xA;  nGRP$X3 &lt;- Grp$X3 - Prt$X3&#xA;  nGRP$X2 &lt;- Grp$X2 - Prt$X2&#xA;  nGRP$X1 &lt;- Grp$X1 - Prt$X1&#xA;  nGRP&#xA;  }&#xA;&#xA;# # combine data from info tables with frequency data&#xA;addinfo &lt;- function(Frq, Info) {&#xA;  for( i in seqalong(Info)) {&#xA;    Frq &lt;- addcolumn(Frq, !!names(Info)[[i]] := Info[[i]])&#xA;  } &#xA;  Frq&#xA;}&#xA;+ENDSRC&#xA;&#xA;+RESULTS: Convenience-Functions&#xA;&#xA;+CAPTION: Question and Response Metadata Preparation&#xA;+name: Question-Response-metadata&#xA;+BEGINSRC R :session Rinddepuni :var Qs=Questions QTypes=QuestionTypes :colnames yes&#xA;:session Rinddepuni :var Qs=Questions QuesTypes=QuestionTypes :results silent&#xA;# # Question Table Preparation&#xA;Keep the dataframe/tibble order the same as in the original table&#xA;/R For Data Science/ Hadley Wickham p. 225&#xA;# # &#34;Sometimes you&#39;d prefer that the order of the levels match the order&#xA;# # of the first appearance in the data. You can do that when creating the&#xA;# # factor by setting levels to \unique(x) \ ... &#xA;Qs$問略 &lt;- factor(Qs$問略, levels = unique(Qs$問略))&#xA;&#xA;Qs$種略 &lt;- FctOrd(Qs$種略)&#xA;Qs$問文 &lt;- FctOrd(Qs$問文)&#xA;as.tibble(Qs)&#xA;# # A tibble: 11 x 3&#xA;種略   問略&#xA;fctr fctr&#xA;# # ... with 1 more variables: 問文 fctr&#xA;&#xA;http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html&#xA;# # &#34;...  Just sorting the dataframe by the variable of interest&#xA;isn’t enough to order the bar chart. In order for the bar chart to&#xA;retain the order of the rows, the X axis variable (i.e. the&#xA;categories) has to be converted into a factor.&#34;&#xA;Qs[1:3,]&#xA;+ENDSRC&#xA;+RESULTS: Question-Response-metadata&#xA;| 種略     | 問略 | 問文                                               |&#xA;|----------+------+----------------------------------------------------|&#xA;| 学生取組 | 出席 | 私はこの授業によく出席した                         |&#xA;| 学生取組 | 発言 | 私は授業内容について質問や発言した                 |&#xA;| 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した） |&#xA;&#xA;+name: RemoveParts&#xA;+BEGINSRC R :session Rinddepuni :var  IDG=InfoDG FDG=FreqDG IGK=InfoGK FGK=FreqGK IKI=InfoKI FKI=FreqKI :colnames yes&#xA;:session Rinddepuni &#xA;:var IDG=InfoDG FDG=FreqDG IGK=InfoGK  &#xA;# # FGK=FreqGK IKI=InfoKI FKI=FreqKI :colnames yes&#xA;&#xA;Remove GK学科 Department numbers part from DG大学 University&#xA;# # Frequencies of DG les GK, University minus Department&#xA;FDGlGK &lt;- RemPRT(FDG, FGK)&#xA;remove KI教員 Teacher numbers fom GK学科 Department&#xA;# # Frequency of GK less KI, Department minus Teacher&#xA;FGKlKI &lt;- RemPRT(FGK, FKI)&#xA;FDGlGK[1:3,]&#xA;+ENDSRC&#xA;+RESULTS: RemoveParts&#xA;|   X5 |  X4 |  X3 |  X2 |  X1 |&#xA;|------+-----+-----+-----+-----|&#xA;| 1491 | 420 | 186 |  28 |  10 |&#xA;|  380 | 530 | 872 | 164 | 177 |&#xA;|  634 | 726 | 602 | 105 |  56 |&#xA;&#xA;+name: AddInfoToFrequencies&#xA;+BEGINSRC R :session Rinddepuni  :colnames yes :var sem=Year-Semester&#xA;as.tibble(FDGlGK)&#xA;# # A tibble: 11 x 5&#xA;X5    X4    X3    X2    X1&#xA;int int int int int&#xA;&#xA;FDGlGK &lt;- addinfo(FDGlGK, IDG)&#xA;FDGlGK &lt;- addinfo(FDGlGK, sem)&#xA;FGKlKI &lt;- addinfo(FGKlKI, IGK)&#xA;FGKlKI &lt;- addinfo(FGKlKI, sem)&#xA;FKI &lt;- addinfo(FKI, IKI) &#xA;FKI &lt;- addinfo(FKI, sem)&#xA;FDGlGK[1:3,]&#xA;&#xA;as.tibble(FDGlGK)&#xA;# # A tibble: 11 x 10&#xA;X5    X4    X3    X2    X1    体    員    枚  学年  学期&#xA;int int int int int chr int int int int&#xA;+ENDSRC&#xA;&#xA;+RESULTS: AddInfoToFrequencies&#xA;|   X5 |  X4 |  X3 |  X2 |  X1 | 体   | 員 |   枚 | 学年 | 学期 |&#xA;|------+-----+-----+-----+-----+------+----+------+------+------|&#xA;| 1491 | 420 | 186 |  28 |  10 | 大学 | 57 | 2403 | 2017 |    2 |&#xA;|  380 | 530 | 872 | 164 | 177 | 大学 | 57 | 2403 | 2017 |    2 |&#xA;|  634 | 726 | 602 | 105 |  56 | 大学 | 57 | 2403 | 2017 |    2 |&#xA;&#xA;+name: AddFactorsToFrequencies&#xA;+BEGINSRC R :session Rinddepuni :colnames yes&#xA;FDGlGK &lt;- addinfo(FDGlGK, Qs)&#xA;FGKlKI &lt;- addinfo(FGKlKI, Qs)&#xA;FKI &lt;- addinfo(FKI, Qs)&#xA;&#xA;FDGlGK[1:3,]&#xA;+ENDSRC&#xA;&#xA;+RESULTS: AddFactorsToFrequencies&#xA;|   X5 |  X4 |  X3 |  X2 |  X1 | 体   | 員 |   枚 | 学年 | 学期 | 種略     | 問略 | 問文                                               |&#xA;|------+-----+-----+-----+-----+------+----+------+------+------+----------+------+----------------------------------------------------|&#xA;| 1491 | 420 | 186 |  28 |  10 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 出席 | 私はこの授業によく出席した                         |&#xA;|  380 | 530 | 872 | 164 | 177 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 発言 | 私は授業内容について質問や発言した                 |&#xA;|  634 | 726 | 602 | 105 |  56 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した） |&#xA;&#xA;+name: ResponseFactorPrep&#xA;+BEGINSRC R :session Rinddepuni :var RespTypes=ResponseTypes :colnames yes&#xA;as.tibble(RespTypes)&#xA;# # A tibble: 5 x 4&#xA;答種     L   答略               答文&#xA;chr int  chr              chr&#xA;1    SO     5   特に       特にそう思う&#xA;&#xA;RespTypes$答略 &lt;- FctOrd(RespTypes$答略)&#xA;RespTypes$答文 &lt;- FctOrd(RespTypes$答文)&#xA;RespTypes$答種 &lt;- FctOrd(RespTypes$答種)&#xA;&#xA;as.tibble(RespTypes)&#xA;# # A tibble: 5 x 4&#xA;答種     L   答略               答文&#xA;fctr int fctr             fctr&#xA;1     SO     5   特に       特にそう思う&#xA;RespTypes[1:3,]&#xA;+ENDSRC&#xA;&#xA;+RESULTS: ResponseFactorPrep&#xA;| 答種 | L | 答略   | 答文               |&#xA;|------+---+--------+--------------------|&#xA;| SO   | 5 | 特に   | 特にそう思う       |&#xA;| SO   | 4 | 多少   | 多少そう思う       |&#xA;| DO   | 3 | どちも | どちらともいえない |&#xA;&#xA;+name: FreqFactorsToLongForm&#xA;+BEGINSRC R :session Rinddepuni :colnames yes&#xA;# #+name: FreqFactorsToLongForm&#xA;# #  R :session Rinddepuni&#xA;Get df/tibbles for Uni, Dep, and Individual ready&#xA;# # Get into Long Format, create a function here later&#xA;RLevels &lt;- strc(&#34;X&#34;, RespTypes$L)&#xA;LongDGlGK - FDGlGK %% gather( RLevels, key=回答, value = 頻度)&#xA;&#xA;LongDGlGK$回答 &lt;- factor(LongDGlGK$回答, order=TRUE, &#xA;                levels = rev(RLevels), labels=rev(RespTypes$答略))&#xA;&#xA;LongGKlKI - FGKlKI %% gather(RLevels, key=回答, value = 頻度)&#xA;LongGKlKI$回答 &lt;- factor(LongGKlKI$回答, order=TRUE, &#xA;                levels = rev(RLevels), labels=rev(RespTypes$答略))&#xA;&#xA;LongKI - FKI %% gather(RLevels, key=回答, value = 頻度)&#xA;LongKI$回答 &lt;- factor(LongKI$回答, order=TRUE, &#xA;                levels = rev(RLevels), labels=rev(RespTypes$答略))&#xA;&#xA;# # merge Uni(DGlGK) and Dep(GKlKI)&#xA;DGlGKGKlKI &lt;- union(LongDGlGK, LongGKlKI)&#xA;&#xA;With this the data is ready to facet by entity $体&#xA;# # and see together with viewports&#xA;DGlGKGKlKIKI &lt;- union(DGlGKGKlKI, LongKI)&#xA;# # factor the entity-type:体 to keep the faceting in order from&#xA;# # smallscale (individual 教員) to largest scale (university 大学)&#xA;DGlGKGKlKIKI$体  &lt;- factor(DGlGKGKlKIKI$体 , order=TRUE, levels=c(&#34;教員&#34;, &#34;学科&#34;, &#34;大学&#34;))&#xA;DGlGKGKlKIKI - DGlGKGKlKIKI %% mutate(割 = round(頻度 / 枚 * 100, digit = 1))&#xA;DGlGKGKlKIKI[1:4,]&#xA;+ENDSRC&#xA;+RESULTS: FreqFactorsToLongForm&#xA;| 体   | 員 | 枚 | 学年 | 学期 | 種略     | 問略 | 問文                                                           | 回答 | 頻度 |  割 |&#xA;|------+----+----+------+------+----------+------+----------------------------------------------------------------+------+------+-----|&#xA;| 教員 |  1 | 68 | 2017 |    2 | 総合評価 | 満足 | 私は総合的に判断してこの授業で満足が得られた                   | 全く |    1 | 1.5 |&#xA;| 教員 |  1 | 68 | 2017 |    2 | 総合評価 | 役立 | 私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた | 全く |    1 | 1.5 |&#xA;| 教員 |  1 | 68 | 2017 |    2 | 教員実施 | 反応 | 教員は学生の反応を確かめながら授業を進めていた                 | 全く |    0 |   0 |&#xA;| 教員 |  1 | 68 | 2017 |    2 | 教員実施 | 熱意 | 教員は熱意を持って授業をしていた                               | 全く |    0 |   0 |&#xA;&#xA;+CAPTION: Question Type Faceting with Individual and Groups&#xA;+name: WariQTypeFacets&#xA;+BEGINSRC R :session Rinddepuni :results graphics :file KIGKDGFacets-H30K.png :var fl=&#34;KIGKDGFacets-H30K.png&#34; :exports both &#xA;:session Rinddepuni :results graphics :file KIGKDGFacets.png &#xA;:var fl=&#34;KIGKDGFacets.png&#34; :exports both &#xA;# # Keep facets in order Ind -  Dep -  Uni 教員 -  学科 -  大学&#xA;DGlGKGKlKIKI$体 &lt;- factor(DGlGKGKlKIKI$体, order=TRUE, levels=c(1, 2, 3), labels =c(&#34;教員&#34;, &#34;学科&#34;, &#34;大学&#34;))&#xA;DGlGKGKlKIKI$体 &lt;- FctOrd(DGlGKGKlKIKI$体)&#xA;png(file=fl, width = 1800, height = 1800 , res = 144) &#xA;ggplot(DGlGKGKlKIKI, aes(回答, 割)) +&#xA; geompoint(aes(group = 問略, color=問略, shape=問略), size = 3) +&#xA; scaleshapemanual(values = 1:nlevels(DGlGKGKlKIKI$問略)) +&#xA; geomline (aes(group = 問略, color=問略)) +&#xA; # replace legends with ggrepel labes for 5 level response &#34;特に&#34;&#xA; ggrepel::geomlabelrepel (data=filter(DGlGKGKlKIKI, 回答 == &#34;特に&#34;),aes(label = strc(問略, 頻度, 割, &#34;%&#34;, sep=&#34;: &#34;)), label.size = NA, segment.color = &#34;grey&#34;, nudgey = 40, nudgex = -1) +&#xA; ggrepel::geomlabelrepel (data=filter(DGlGKGKlKIKI, 回答 == &#34;あまり&#34;), aes(label = strc(問略, 頻度, 割, &#34;%&#34;, sep=&#34;: &#34;)), label.size = NA, segment.color = &#34;grey&#34;, nudgey = 40, nudgex = -5) +&#xA; theme( &#xA;      axis.title = elementtext (size = rel(.9)),&#xA;      axis.text.x = elementtext (size = rel(1.2), angle = 45),&#xA;      axis.title.y = elementtext (angle = 0),&#xA;      strip.text = elementtext (size = rel(1.5)),&#xA;      plot.title = elementtext(size = rel(1.5), color=&#34;black&#34;),&#xA;      legend.title = elementtext(rel(4)),&#xA;      legend.text  = elementtext(size=12)) +&#xA; labs( title = paste( &#34;教員,学科,大学のアンケート結果%&#34;),&#xA;      color= &#34;設問&#34;, shape=&#34;設問&#34; ) +&#xA;# # replace labs labels with ggrepel above&#xA; facetwrap( 種略 ~ 体 , ncol = 3, nrow = 3) + &#xA;  ylim( -10 , 110) +&#xA;  guides(color=FALSE, shape=FALSE)&#xA;&#xA;  dev.off()&#xA; #+END_SRC&#xA;&#xA; るびきち： 巨大なオーガナイズシステム「org-mode」の世界&#xA;    http://emacs.rubikitch.com/sd1502-org-mode/&#xA; (fn:1) I mentioned Koreo Kinoshita&#39;s books in a post about using Guile Scheme to implement D.R.Y. for teachers&#xA;     https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart&#xA; (fn:2) Reproducible Research:&#xA;     https://orgmode.org/worg/org-contrib/babel/uses.html#orgbfd912c&#xA; #emacs #orgmode #R #ggplot2 #DataVisualization]]&gt;</description>
      <content:encoded><![CDATA[<p>FDアンケート結果の視覚化への挑戦 1。フリーソフトのエディターEmacs, orgmodeとフリーな言語R, ggplot2と遊びながら、情報デザインを考える機会です。
Faculty Development questionnaire results give me a chance to re-visit Edward Tufte&#39;s <em>Beautiful Evidence</em> and attempt to implement his design ideas with emacs, org-mode and R, ggplot2.
<img src="https://i.snap.as/gTCCOlM.png" alt="" title="Faceted Visualization of Questionnaire results"/></p>

<p>Emacs org-modeの表には無駄なインクがありません。 簡単に生成するテーブル(表)は木下是雄さんの「レポートの組み立て方 」で見る表に負けなません、 すっきりしている。
The html pages exported by org-mode have a high ink-to-data ratio. They remind me of a book about writing for scientists. (fn:1)</p>

<p><img src="https://i.snap.as/QWGqqDE.png" alt="" title="Org-mode generated these clear html page tables for the Questions and other text."/></p>

<p>色々なデータ表をブラウザーで一目(one eye-span)で見ることができる。まとめて見えるようにするのが一つの原則(Principle).
The browser lets us see several data tables within one eye-span. Orgmode-generated html with some .css styling can implement Edward Tufte&#39;s design principle: “one eye-span.”</p>

<p><img src="https://i.snap.as/BYV1UzE.png" alt="" title="Data Tables"/>

Emacでデータ入力するときは見た目は違う。
In emacs the tables have a different appearance.
<img src="https://i.snap.as/A6eUr3N.jpg" alt=""/></p>

<h3 id="emacs-org-mode-and-r-ggplot2-code">Emacs org-mode and R ggplot2 code</h3>

<p>It&#39;s awkward but it works. It may help to get started thinking about <em>Reproducible Research</em>. (fn:2)
エレガントなコードではないけど、動く。</p>

<pre><code>#+TITLE: Combined Views 教員, 学科, 大学
#+STARTUP: showall
#+OPTIONS: toc:nil num:nil timestamp:nil ^:{} H:4

#+HTML_HEAD: &lt;style&gt; @page { size: 210mm 297mm; margin: 4mm; margin-bottom: 6mm; } &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; h1.title { display: none; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; h1, h2, h3, h4 { font-weight: 500; font-size: 1.2em; clear: left;}  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; div#postamble { display: none; }  &lt;/style&gt;

# # doesn&#39;t clear the following tables
#+HTML_HEAD: &lt;style&gt; div#outline-container-SetumonJouhou { clear: right; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; div#outline-container-DataJouhou { clear: right; }  &lt;/style&gt;
# #+HTML_HEAD: &lt;style&gt; div#outline-container-KekkaJouhou { clear: right; }&lt;/style&gt;

# 
#+HTML_HEAD: &lt;style&gt; h3 { clear: left; display: none; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; div.outline-3 { clear: left; }  &lt;/style&gt;
# #+HTML_HEAD: &lt;style&gt; #outline-container-KekkaJouhou { clear: left; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table {margin-bottom: 1em; margin-right: 1em; float: left; page-break-inside: avoid;}  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; span.table-number { display: none; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; span.figure-number { display: none; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; td { padding: 3px; }   &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table#QuestionTypes { float: left; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; table#ResponseTypes { margin: 1em; clear: right; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table#Info_DG { float: left; } &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; table#Info_GK { float: left; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; table#Info_KI { float: left; clear: right }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table#Freq_DG { float: left; } &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; table#Freqs_GK { float: left; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; table#Freq_KI { float: left; clear: right }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table#QuestionsAsVariables td { font-size: 10pt; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; table#TidyDataOuput td { font-size: 10pt; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; div#outline-container-TidyData { clear: left; page-break-before: always; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; pre.src, pre.example { border: none; margin: .5em;  box-shadow: none; padding: 0; }  &lt;/style&gt;
#+HTML_HEAD: &lt;style&gt; pre.example { margin-left: 4em; padding-left: 1em; border-left: thin solid grey; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; div#outline-container-Data h2 { display: none; }  &lt;/style&gt;

#+HTML_HEAD: &lt;style&gt; div.org-src-container { clear: left; }  &lt;/style&gt;
# #+HTML_HEAD: &lt;style&gt; img { width: 100%; }  &lt;/style&gt;
# adjust width of image to fit on pages under frequency data tables
#+HTML_HEAD: &lt;style&gt; img { width: 700px; } &lt;/style&gt;

* 設問情報
:PROPERTIES:
:CUSTOM_ID: SetsumonJouhou
:END:

** 質問
#+CAPTION: Questions
#+name: Questions
| 種略     | 問略 | 問文                                                                  |
|----------+------+-----------------------------------------------------------------------|
| 学生取組 | 出席 | 私はこの授業によく出席した                                            |
| 学生取組 | 発言 | 私は授業内容について質問や発言した                                    |
| 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した）                    |
| 教員実施 | 聞取 | 教員の声は聞き取りやすかった。                                        |
| 教員実施 | 資料 | 教員の板書（またはPPT・配布資料など）は読みやすかった（見やすかった） |
| 教員実施 | 時刻 | 教員は授業の開始・終了の時刻を守ろうとしていた                        |
| 教員実施 | 反応 | 教員は学生の反応を確かめながら授業を進めていた                        |
| 教員実施 | 熱意 | 教員は熱意を持って授業をしていた                                      |
| 総合評価 | 理解 | 私はこの授業内容を理解できた                                          |
| 総合評価 | 役立 | 私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた        |
| 総合評価 | 満足 | 私は総合的に判断してこの授業で満足が得られた                          |

** 質問と回答の分類
#+CAPTION: Question Types
#+name: QuestionTypes
| 種略     | 種文                           |
|----------+--------------------------------|
| 学生取組 | 学生の授業取り組みに関する質問 |
| 教員実施 | 教員の授業実施方法に関する質問 |
| 総合評価 | 総合的評価に関する質問         |

#+CAPTION: Response Types
#+name: ResponseTypes
| 答種 | L | 答略   | 答文               |
|------+---+--------+--------------------|
| SO   | 5 | 特に   | 特にそう思う       |
| SO   | 4 | 多少   | 多少そう思う       |
| DO   | 3 | どちも | どちらともいえない |
| NO   | 2 | あまり | あまりそう思わない |
| NO   | 1 | 全く   | 全くそう思わない   |

* データ情報
:PROPERTIES:
:CUSTOM_ID: DataJouhou
:END:

*** 情報の表
:PROPERTIES:
:CUSTOM_ID: Info_Tables
:END:

#+CAPTION: 学年、学期
#+name: Year-Semester
| 学年 | 学期 |
|------+------|
| 2018 |    2 |

#+CAPTION: 体とコード
#+name: Tai-Kanji-CD
| 体           | 体種 | CD |
|--------------+------+----|
| 南九州大学   | 大学 | DG |
| 教養センター | 学科 | GK |
| 教職員       | 教員 | KI |

*** 大学、学科、教員の情報
:PROPERTIES:
:CUSTOM_ID: EntityDataJouhou
:END:
#+CAPTION: 大学の情報
#+name: Info_DG
| 体   | 員 |   枚 |
|------+----+------|
| 大学 | 57 | 2403 |

#+CAPTION: 学科の情報
#+name: Info_GK
| 体   | 員 |  枚 |
|------+----+-----|
| 学科 |  6 | 276 |

#+CAPTION: 教員の情報
#+name: Info_KI
| 体   | 員 | 枚 |
|------+----+----|
| 教員 |  1 | 68 |

** 結果情報
:PROPERTIES:
:CUSTOM_ID: KekkaJouhou
:END:
#+CAPTION: 教員の結果
#+name: Freq_KI
|  5 |  4 |  3 |  2 | 1 |
|----+----+----+----+---|
| 33 | 28 |  6 |  1 | 0 |
|  8 | 27 | 19 |  9 | 5 |
|  8 | 25 | 22 | 12 | 1 |
| 37 | 25 |  6 |  0 | 0 |
| 21 | 34 | 11 |  2 | 0 |
| 49 | 16 |  3 |  0 | 0 |
| 47 | 16 |  5 |  0 | 0 |
| 56 | 11 |  1 |  0 | 0 |
| 25 | 31 |  7 |  5 | 0 |
| 17 | 33 | 15 |  2 | 1 |
| 19 | 38 |  8 |  2 | 1 |

#+CAPTION: 学科の結果
#+name: Freq_GK
|   5 |   4 |   3 |  2 |  1 |
|-----+-----+-----+----+----|
| 198 |  59 |  16 |  3 |  0 |
|  39 |  86 | 102 | 26 | 22 |
|  50 |  96 |  90 | 29 |  9 |
| 130 |  91 |  40 | 10 |  4 |
|  98 | 107 |  55 | 12 |  3 |
| 174 |  70 |  26 |  4 |  2 |
| 125 |  95 |  48 |  5 |  3 |
| 161 |  81 |  30 |  2 |  1 |
|  99 | 114 |  45 | 13 |  5 |
|  95 | 105 |  65 |  8 |  3 |
|  89 | 120 |  51 |  9 |  7 |

#+CAPTION: 大学の結果
#+name: Freq_DG
|    5 |   4 |   3 |   2 |   1 |
|------+-----+-----+-----+-----|
| 1689 | 479 | 202 |  31 |  10 |
|  419 | 616 | 974 | 190 | 199 |
|  684 | 822 | 692 | 134 |  65 |
| 1341 | 670 | 293 |  69 |  28 |
| 1200 | 695 | 374 |  86 |  42 |
| 1702 | 480 | 169 |  28 |  17 |
| 1315 | 652 | 349 |  52 |  33 |
| 1537 | 585 | 236 |  21 |  19 |
|  938 | 940 | 412 |  73 |  34 |
| 1328 | 676 | 325 |  43 |  26 |
| 1172 | 781 | 356 |  55 |  34 |

** データ視覚化の画像
#+RESULTS: WariQTypeFacets
[[file:KI_GK_DG_Facets-H30K.png]]

* Code for Image: Data Visualization
:PROPERTIES:
:CUSTOM_ID: Images-Data-Visualizations
:END:

#+name: evaluate-now
#+BEGIN_SRC emacs-lisp
(setq org-confirm-babel-evaluate nil)
#+END_SRC

#+RESULTS: evaluate-now

#+name: R-Libraries
#+BEGIN_SRC R  :session Rinddepuni :results silent
library(tidyverse)
library(stringr)
library(ggrepel)
library(forcats)
#+END_SRC

#+name: Convenience-Functions
#+BEGIN_SRC R  :session Rinddepuni
# # Maintain order of data from original tables
FctOrd &lt;- function(col) {
  col &lt;- factor(col, levels=unique(col))
  }

# Remove Part from Group
# # Minus Prt$`5` 4 3 2 1 from Grp$`5`
RemPRT &lt;- function(Grp, Prt) {
  nGRP &lt;- Grp
  nGRP$`X5` &lt;- Grp$`X5` - Prt$`X5`
  nGRP$`X4` &lt;- Grp$`X4` - Prt$`X4`
  nGRP$`X3` &lt;- Grp$`X3` - Prt$`X3`
  nGRP$`X2` &lt;- Grp$`X2` - Prt$`X2`
  nGRP$`X1` &lt;- Grp$`X1` - Prt$`X1`
  nGRP
  }

# # combine data from info tables with frequency data
add_info &lt;- function(Frq, Info) {
  for( i in seq_along(Info)) {
    Frq &lt;- add_column(Frq, !!names(Info)[[i]] := Info[[i]])
  } 
  Frq
}
#+END_SRC

#+RESULTS: Convenience-Functions


#+CAPTION: Question and Response Metadata Preparation
#+name: Question-Response-metadata
#+BEGIN_SRC R :session Rinddepuni :var Qs=Questions QTypes=QuestionTypes :colnames yes
# :session Rinddepuni :var Qs=Questions QuesTypes=QuestionTypes :results silent
# # Question Table Preparation
# Keep the dataframe/tibble order the same as in the original table
# /R For Data Science/ Hadley Wickham p. 225
# # &#34;Sometimes you&#39;d prefer that the order of the levels match the order
# # of the first appearance in the data. You can do that when creating the
# # factor by setting levels to \unique(x) \ ... 
Qs$問略 &lt;- factor(Qs$問略, levels = unique(Qs$問略))

Qs$種略 &lt;- FctOrd(Qs$種略)
Qs$問文 &lt;- FctOrd(Qs$問文)
# as.tibble(Qs)
# # A tibble: 11 x 3
#        種略   問略
#      &lt;fctr&gt; &lt;fctr&gt;
# # ... with 1 more variables: 問文 &lt;fctr&gt;

# http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html
# # &#34;...  Just sorting the dataframe by the variable of interest
# isn’t enough to order the bar chart. In order for the bar chart to
# retain the order of the rows, the X axis variable (i.e. the
# categories) has to be converted into a factor.&#34;
Qs[1:3,]
#+END_SRC
#+RESULTS: Question-Response-metadata
| 種略     | 問略 | 問文                                               |
|----------+------+----------------------------------------------------|
| 学生取組 | 出席 | 私はこの授業によく出席した                         |
| 学生取組 | 発言 | 私は授業内容について質問や発言した                 |
| 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した） |

#+name: RemoveParts
#+BEGIN_SRC R :session Rinddepuni :var  I_DG=Info_DG F_DG=Freq_DG I_GK=Info_GK F_GK=Freq_GK I_KI=Info_KI F_KI=Freq_KI :colnames yes
# :session Rinddepuni 
# :var I_DG=Info_DG F_DG=Freq_DG I_GK=Info_GK  
# # F_GK=Freq_GK I_KI=Info_KI F_KI=Freq_KI :colnames yes

# Remove GK学科 Department numbers part from DG大学 University
# # Frequencies of DG les GK, University minus Department
F_DGlGK &lt;- RemPRT(F_DG, F_GK)
# remove KI教員 Teacher numbers fom GK学科 Department
# # Frequency of GK less KI, Department minus Teacher
F_GKlKI &lt;- RemPRT(F_GK, F_KI)
F_DGlGK[1:3,]
#+END_SRC
#+RESULTS: RemoveParts
|   X5 |  X4 |  X3 |  X2 |  X1 |
|------+-----+-----+-----+-----|
| 1491 | 420 | 186 |  28 |  10 |
|  380 | 530 | 872 | 164 | 177 |
|  634 | 726 | 602 | 105 |  56 |

#+name: AddInfoToFrequencies
#+BEGIN_SRC R :session Rinddepuni  :colnames yes :var sem=Year-Semester
# as.tibble(F_DGlGK)
# # A tibble: 11 x 5
#       X5    X4    X3    X2    X1
#    &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;

F_DGlGK &lt;- add_info(F_DGlGK, I_DG)
F_DGlGK &lt;- add_info(F_DGlGK, sem)
F_GKlKI &lt;- add_info(F_GKlKI, I_GK)
F_GKlKI &lt;- add_info(F_GKlKI, sem)
F_KI &lt;- add_info(F_KI, I_KI) 
F_KI &lt;- add_info(F_KI, sem)
F_DGlGK[1:3,]

# as.tibble(F_DGlGK)
# # A tibble: 11 x 10
#       X5    X4    X3    X2    X1    体    員    枚  学年  学期
#    &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
#+END_SRC

#+RESULTS: AddInfoToFrequencies
|   X5 |  X4 |  X3 |  X2 |  X1 | 体   | 員 |   枚 | 学年 | 学期 |
|------+-----+-----+-----+-----+------+----+------+------+------|
| 1491 | 420 | 186 |  28 |  10 | 大学 | 57 | 2403 | 2017 |    2 |
|  380 | 530 | 872 | 164 | 177 | 大学 | 57 | 2403 | 2017 |    2 |
|  634 | 726 | 602 | 105 |  56 | 大学 | 57 | 2403 | 2017 |    2 |

#+name: AddFactorsToFrequencies
#+BEGIN_SRC R :session Rinddepuni :colnames yes
F_DGlGK &lt;- add_info(F_DGlGK, Qs)
F_GKlKI &lt;- add_info(F_GKlKI, Qs)
F_KI &lt;- add_info(F_KI, Qs)

F_DGlGK[1:3,]
#+END_SRC

#+RESULTS: AddFactorsToFrequencies
|   X5 |  X4 |  X3 |  X2 |  X1 | 体   | 員 |   枚 | 学年 | 学期 | 種略     | 問略 | 問文                                               |
|------+-----+-----+-----+-----+------+----+------+------+------+----------+------+----------------------------------------------------|
| 1491 | 420 | 186 |  28 |  10 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 出席 | 私はこの授業によく出席した                         |
|  380 | 530 | 872 | 164 | 177 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 発言 | 私は授業内容について質問や発言した                 |
|  634 | 726 | 602 | 105 |  56 | 大学 | 57 | 2403 | 2017 |    2 | 学生取組 | 取組 | 私はこの科目に積極的に取り組んだ（予習と復習した） |

#+name: ResponseFactorPrep
#+BEGIN_SRC R :session Rinddepuni :var RespTypes=ResponseTypes :colnames yes
# as.tibble(RespTypes)
# # A tibble: 5 x 4
#    答種     L   答略               答文
#   &lt;chr&gt; &lt;int&gt;  &lt;chr&gt;              &lt;chr&gt;
# 1    SO     5   特に       特にそう思う

RespTypes$答略 &lt;- FctOrd(RespTypes$答略)
RespTypes$答文 &lt;- FctOrd(RespTypes$答文)
RespTypes$答種 &lt;- FctOrd(RespTypes$答種)

# as.tibble(RespTypes)
# # A tibble: 5 x 4
#     答種     L   答略               答文
#   &lt;fctr&gt; &lt;int&gt; &lt;fctr&gt;             &lt;fctr&gt;
# 1     SO     5   特に       特にそう思う
RespTypes[1:3,]
#+END_SRC

#+RESULTS: ResponseFactorPrep
| 答種 | L | 答略   | 答文               |
|------+---+--------+--------------------|
| SO   | 5 | 特に   | 特にそう思う       |
| SO   | 4 | 多少   | 多少そう思う       |
| DO   | 3 | どちも | どちらともいえない |

#+name: FreqFactorsToLongForm
#+BEGIN_SRC R :session Rinddepuni :colnames yes
# #+name: FreqFactorsToLongForm
# #  R :session Rinddepuni
# Get df/tibbles for Uni, Dep, and Individual ready
# # Get into Long Format, create a function here later
RLevels &lt;- str_c(&#34;X&#34;, RespTypes$L)
Long_DGlGK &lt;- F_DGlGK %&gt;% gather( RLevels, key=回答, value = 頻度)

Long_DGlGK$回答 &lt;- factor(Long_DGlGK$回答, order=TRUE, 
                levels = rev(RLevels), labels=rev(RespTypes$答略))

Long_GKlKI &lt;- F_GKlKI %&gt;% gather(RLevels, key=回答, value = 頻度)
Long_GKlKI$回答 &lt;- factor(Long_GKlKI$回答, order=TRUE, 
                levels = rev(RLevels), labels=rev(RespTypes$答略))

Long_KI &lt;- F_KI %&gt;% gather(RLevels, key=回答, value = 頻度)
Long_KI$回答 &lt;- factor(Long_KI$回答, order=TRUE, 
                levels = rev(RLevels), labels=rev(RespTypes$答略))

# # merge Uni(DGlGK) and Dep(GKlKI)
DGlGK_GKlKI &lt;- union(Long_DGlGK, Long_GKlKI)

# With this the data is ready to facet by entity $体
# # and see together with viewports
DGlGK_GKlKI_KI &lt;- union(DGlGK_GKlKI, Long_KI)
# # factor the entity-type:体 to keep the faceting in order from
# # smallscale (individual 教員) to largest scale (university 大学)
DGlGK_GKlKI_KI$体  &lt;- factor(DGlGK_GKlKI_KI$体 , order=TRUE, levels=c(&#34;教員&#34;, &#34;学科&#34;, &#34;大学&#34;))
DGlGK_GKlKI_KI &lt;- DGlGK_GKlKI_KI %&gt;% mutate(割 = round(頻度 / 枚 * 100, digit = 1))
DGlGK_GKlKI_KI[1:4,]
#+END_SRC
#+RESULTS: FreqFactorsToLongForm
| 体   | 員 | 枚 | 学年 | 学期 | 種略     | 問略 | 問文                                                           | 回答 | 頻度 |  割 |
|------+----+----+------+------+----------+------+----------------------------------------------------------------+------+------+-----|
| 教員 |  1 | 68 | 2017 |    2 | 総合評価 | 満足 | 私は総合的に判断してこの授業で満足が得られた                   | 全く |    1 | 1.5 |
| 教員 |  1 | 68 | 2017 |    2 | 総合評価 | 役立 | 私はこの授業で学んだ内容はなんらかの形で将来的に役立つと感じた | 全く |    1 | 1.5 |
| 教員 |  1 | 68 | 2017 |    2 | 教員実施 | 反応 | 教員は学生の反応を確かめながら授業を進めていた                 | 全く |    0 |   0 |
| 教員 |  1 | 68 | 2017 |    2 | 教員実施 | 熱意 | 教員は熱意を持って授業をしていた                               | 全く |    0 |   0 |

#+CAPTION: Question Type Faceting with Individual and Groups
#+name: WariQTypeFacets
#+BEGIN_SRC R :session Rinddepuni :results graphics :file KI_GK_DG_Facets-H30K.png :var fl=&#34;KI_GK_DG_Facets-H30K.png&#34; :exports both 
# :session Rinddepuni :results graphics :file KI_GK_DG_Facets.png 
# :var fl=&#34;KI_GK_DG_Facets.png&#34; :exports both 
# # Keep facets in order Ind -&gt; Dep -&gt; Uni 教員 -&gt; 学科 -&gt; 大学
# DGlGK_GKlKI_KI$体 &lt;- factor(DGlGK_GKlKI_KI$体, order=TRUE, levels=c(1, 2, 3), labels =c(&#34;教員&#34;, &#34;学科&#34;, &#34;大学&#34;))
# DGlGK_GKlKI_KI$体 &lt;- FctOrd(DGlGK_GKlKI_KI$体)
png(file=fl, width = 1800, height = 1800 , res = 144) 
ggplot(DGlGK_GKlKI_KI, aes(回答, 割)) +
 geom_point(aes(group = 問略, color=問略, shape=問略), size = 3) +
 scale_shape_manual(values = 1:nlevels(DGlGK_GKlKI_KI$問略)) +
 geom_line (aes(group = 問略, color=問略)) +
 # replace legends with ggrepel labes for 5 level response &#34;特に&#34;
 ggrepel::geom_label_repel (data=filter(DGlGK_GKlKI_KI, 回答 == &#34;特に&#34;),aes(label = str_c(問略, 頻度, 割, &#34;%&#34;, sep=&#34;: &#34;)), label.size = NA, segment.color = &#34;grey&#34;, nudge_y = 40, nudge_x = -1) +
 ggrepel::geom_label_repel (data=filter(DGlGK_GKlKI_KI, 回答 == &#34;あまり&#34;), aes(label = str_c(問略, 頻度, 割, &#34;%&#34;, sep=&#34;: &#34;)), label.size = NA, segment.color = &#34;grey&#34;, nudge_y = 40, nudge_x = -5) +
 theme( 
      axis.title = element_text (size = rel(.9)),
      axis.text.x = element_text (size = rel(1.2), angle = 45),
      axis.title.y = element_text (angle = 0),
      strip.text = element_text (size = rel(1.5)),
      plot.title = element_text(size = rel(1.5), color=&#34;black&#34;),
      legend.title = element_text(rel(4)),
      legend.text  = element_text(size=12)) +
 labs( title = paste( &#34;教員,学科,大学のアンケート結果%&#34;),
      color= &#34;設問&#34;, shape=&#34;設問&#34; ) +
# # replace labs labels with ggrepel above
 facet_wrap( 種略 ~ 体 , ncol = 3, nrow = 3) + 
  ylim( -10 , 110) +
  guides(color=FALSE, shape=FALSE)

  dev.off()
 #+END_SRC

</code></pre>
<ul><li>るびきち： 巨大なオーガナイズシステム「org-mode」の世界
<ul><li><a href="http://emacs.rubikitch.com/sd1502-org-mode/">http://emacs.rubikitch.com/sd1502-org-mode/</a></li></ul></li>
<li>(fn:1) I mentioned Koreo Kinoshita&#39;s books in a post about using Guile Scheme to implement D.R.Y. for teachers
<ul><li><a href="https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart">https://write.as/bs2gs/from-csv-file-generate-roll-sheet-and-seat-chart</a></li></ul></li>
<li>(fn:2) Reproducible Research:
<ul><li><a href="https://orgmode.org/worg/org-contrib/babel/uses.html#orgbfd912c">https://orgmode.org/worg/org-contrib/babel/uses.html#orgbfd912c</a>
<a href="https://write.as/bs2facdev/tag:emacs" class="hashtag"><span>#</span><span class="p-category">emacs</span></a> <a href="https://write.as/bs2facdev/tag:orgmode" class="hashtag"><span>#</span><span class="p-category">orgmode</span></a> <a href="https://write.as/bs2facdev/tag:R" class="hashtag"><span>#</span><span class="p-category">R</span></a> <a href="https://write.as/bs2facdev/tag:ggplot2" class="hashtag"><span>#</span><span class="p-category">ggplot2</span></a> <a href="https://write.as/bs2facdev/tag:DataVisualization" class="hashtag"><span>#</span><span class="p-category">DataVisualization</span></a></li></ul></li></ul>
]]></content:encoded>
      <guid>https://write.as/bs2facdev/anketo-questionnaire-visualization-with-r-ggplot2</guid>
      <pubDate>Thu, 07 Mar 2019 13:11:23 +0000</pubDate>
    </item>
  </channel>
</rss>