<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Miscellaneous | AQM 2025</title>
    <link>/misc/</link>
      <atom:link href="/misc/index.xml" rel="self" type="application/rss+xml" />
    <description>Miscellaneous</description>
    <generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>©2026</copyright>
    <image>
      <url>/img/avatar.png</url>
      <title>Miscellaneous</title>
      <link>/misc/</link>
    </image>
    
    <item>
      <title>Doing References in RMarkdown</title>
      <link>/misc/citations/</link>
      <pubDate>Thu, 14 Oct 2021 00:00:00 +0000</pubDate>
      <guid>/misc/citations/</guid>
      <description>&lt;p&gt;Doing references is not very complicated in Rmarkdown. One option is to struggle and do everything manually, but there is a much better way that is quicker and more reliable.&lt;/p&gt;
&lt;h2 id=&#34;getting-started&#34;&gt;Getting Started&lt;/h2&gt;
&lt;p&gt;To start with, you will need a file that contains all the bibliographic information about the texts you are using for writing (you can update it any time you want). The file can be in different formats, but I suggest you use the &lt;code&gt;bib&lt;/code&gt; format, which is supported by most reference managers and is primarily used when working with typesetting software &lt;em&gt;Latex&lt;/em&gt;. The &lt;code&gt;bib&lt;/code&gt; file will have one or many entries like this, one for each article/book/etc. you add:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;@article{king2000making,
  title={Making the most of statistical analyses: Improving interpretation and presentation},
  author={King, Gary and Tomz, Michael and Wittenberg, Jason},
  journal={American journal of political science},
  pages={347--361},
  year={2000}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There is a unique identifier of the item, &lt;code&gt;king2000making&lt;/code&gt; in this case, as well as the normal bibliographic information like the title and year of publication. There are various types of items, like articles or books.&lt;/p&gt;
&lt;p&gt;The good news is: you don&amp;rsquo;t need to write these files yourself. Programs like reference managers will do this for you. All you have to do to get these files is to put the URLs or &lt;a href=&#34;https://library.uic.edu/help/article/1966/what-is-a-doi-and-how-do-i-use-them-in-citations&#34;&gt;DOI (Digital Object Identifier)&lt;/a&gt; numbers of articles or International Standard Book Number (ISBN) of books into the programs and check that the imported details look correct/reasonable. The even better news is that based on these details, you will only need to mention the unique identifier of the item (like &lt;code&gt;king2000making&lt;/code&gt;) when writing the text and RMarkdown will make an citation and a reference according to the citation style you select.&lt;/p&gt;
&lt;h2 id=&#34;step-1-get-a-bib-file&#34;&gt;Step 1: Get a &lt;code&gt;bib&lt;/code&gt; File&lt;/h2&gt;
&lt;p&gt;If you are already using any reference manager like Zotero or Mendeley, enter the texts you need into the manager as normal and export the &lt;code&gt;bib&lt;/code&gt; (&lt;code&gt;Bibtex&lt;/code&gt;) file into the project directory (where your &lt;code&gt;Rproj&lt;/code&gt; file is located). Here is a way to do it in &lt;a href=&#34;https://unimelb.libguides.com/latexbibtex/zotero&#34;&gt;Zotero&lt;/a&gt; and in &lt;a href=&#34;https://www.imperial.ac.uk/media/imperial-college/administration-and-support-services/library/public/LaTeX-and-Mendeley-apr-2019.pdf&#34;&gt;Mendeley&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have never used a reference manager, you can either install one or use a web-version of Zotero &lt;a href=&#34;https://zbib.org/&#34;&gt;https://zbib.org/&lt;/a&gt; to generate a &lt;code&gt;bib&lt;/code&gt; file. Put the URLs to the articles or the DOI numbers. If necessary, you can enter the details manually.  Always check if the imported data look correct: sometimes, page numbers look weird or the titles are not imported correctly. This happens relatively rare, but better always double-check. Scroll to export and select &lt;em&gt;Download Bibtex&lt;/em&gt;. Put this &lt;code&gt;bib&lt;/code&gt; file into the project directory (where your &lt;code&gt;Rproj&lt;/code&gt; file is located).&lt;/p&gt;
&lt;p&gt;You can check if &lt;code&gt;bib&lt;/code&gt; file has data and open in Rstudio by clicking on it from the Files pane (or a text editor that supports &lt;code&gt;txt&lt;/code&gt; files).&lt;/p&gt;
&lt;h2 id=&#34;step-2-add-bibliography-related-parameters-to-yaml-in-rmd-file&#34;&gt;Step 2: Add Bibliography-related Parameters to YAML in &lt;code&gt;Rmd&lt;/code&gt; file&lt;/h2&gt;
&lt;p&gt;Now you need to tell RMarkdown that you will want it to use this &lt;code&gt;bib&lt;/code&gt; file. Let&amp;rsquo;s say you now have the &lt;code&gt;citations.bib&lt;/code&gt; file in the folder of the project folder and your &lt;code&gt;Rmd&lt;/code&gt; file is located there as well. In the YAML header, you will need to add the following lines and I want Chicago-style in-text citations:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;bibliography: citations.bib
biblio-style: apsr
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;bibliography&lt;/code&gt; parameter tells R which file to use and &lt;code&gt;biblio-style&lt;/code&gt; defines the style. Style &lt;em&gt;apsr&lt;/em&gt; is the style used in American Political Science Review, and this is the Chicago author-date style.&lt;/p&gt;
&lt;p&gt;In case you need to use a very specific style that is not built-in, it will probably be available here: &lt;a href=&#34;https://github.com/citation-style-language/styles&#34;&gt;https://github.com/citation-style-language/styles&lt;/a&gt;. Styles are saved in &lt;code&gt;csl&lt;/code&gt; files, so you will just need to download the file you need, put it in the project folder, and instead of &lt;code&gt;biblio-style&lt;/code&gt; put &lt;code&gt;csl&lt;/code&gt; parameter with the name of the respective file. For instance, if I wanted to use the style of &lt;em&gt;American Political Science Association&lt;/em&gt;, I would write it like this if saved the &lt;code&gt;csl&lt;/code&gt; file as &lt;code&gt;american-political-science-association.csl&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;bibliography: citations.bib
csl: american-political-science-association.csl
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can download the latest version of Mannheim Political Science group citation style from the library website: &lt;a href=&#34;https://www.bib.uni-mannheim.de/services/literaturverwaltungsprogramme/zitationsstile/&#34;&gt;https://www.bib.uni-mannheim.de/services/literaturverwaltungsprogramme/zitationsstile/&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;step-3-add-references-section-to-the-document&#34;&gt;Step 3: Add &lt;em&gt;References&lt;/em&gt; Section to the Document&lt;/h2&gt;
&lt;p&gt;The bibliography is typically placed at the end of the document, so your last heading should be something like &lt;code&gt;# References&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;step-4-reference-items-in-the-text&#34;&gt;Step 4: Reference Items in the Text&lt;/h2&gt;
&lt;p&gt;If you are using the Visual markdown editor mode, &lt;em&gt;Insert -&amp;gt; Citation&lt;/em&gt;  will do most of the job. You just need to find the text you want to cite and the citation will be inserted at the place you selected. If you need something like &lt;em&gt;Blah blah (Smith 2004)&lt;/em&gt;, just select the text from the list and you&amp;rsquo;re good. If you want the format: &lt;em&gt;Smith (2004) claims blah &amp;hellip;&lt;/em&gt; select the &lt;em&gt;in-text citation&lt;/em&gt; option.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re using source editor, you will need to write out the references manually. Each item in your &lt;code&gt;bib&lt;/code&gt; list can be referenced in the main text, so you will need to see these identifiers. I just have the &lt;code&gt;bib&lt;/code&gt; file opened in a tab in Rstudio and check the identifier once I need it.&lt;/p&gt;
&lt;p&gt;Citations go inside square brackets and are separated by semicolons. Each citation must have a key, composed of &amp;lsquo;@&amp;rsquo; + the citation identifier from the database, and may optionally have a prefix, a locator, and a suffix. Putting &lt;code&gt;[]&lt;/code&gt; ensures that there are parenthesis around the citation.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].

Blah blah [@smith04; @doe99].
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A minus sign &lt;code&gt;-&lt;/code&gt; before the &lt;code&gt;@&lt;/code&gt; will suppress mention of the author in the citation. This can be useful when the author is already mentioned in the text and you only need to include the year:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Smith says blah [-@smith04].
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is how you get the in-text citations like &lt;em&gt;Smith (2004) says blah&lt;/em&gt; and &lt;em&gt;Smith (2004, 33) says blah&lt;/em&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;@smith04 says blah

@smith04 [p. 33] says blah
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;making-changes&#34;&gt;Making Changes&lt;/h2&gt;
&lt;p&gt;You can always manually add a reference or a few into the &lt;code&gt;bib&lt;/code&gt; file, add a different file, or generate a new file and update the current one. The only requirement is that the identifiers for items remain constant, and if you are using the same software as last time for generating a &lt;code&gt;bib&lt;/code&gt; file, there will be no differences in 99% of the cases. You will need to re-compile the output files to see the effects.&lt;/p&gt;
&lt;p&gt;You can use the same &lt;code&gt;bib&lt;/code&gt; file with multiple documents (as long as you specify the path to it correctly in each of them).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Merge conflicts</title>
      <link>/misc/merge-conflict/</link>
      <pubDate>Wed, 13 Oct 2021 00:00:00 +0000</pubDate>
      <guid>/misc/merge-conflict/</guid>
      <description>&lt;p&gt;A &lt;strong&gt;merge conflict&lt;/strong&gt; is a result of multiple people editing the same lines of the document simultaneously (or one person having edit the lines yesterday and another person not &lt;code&gt;pull&lt;/code&gt;ing before editing the same lines). In such a case, &lt;code&gt;git&lt;/code&gt; needs human help to decide which lines to keep and/or how to merge them. If this is happening to you, &lt;code&gt;git&lt;/code&gt; will refuse to merge files smoothly and will ask you to intervene and do some extra steps. Dealing with merge conflicts is most often not too complicated, but it&amp;rsquo;s better to prevent them from happening and/or to make them easier to resolve.&lt;/p&gt;
&lt;p&gt;This how a merge conflict looks like in your files:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;merge-conflict-identifiers.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;To &lt;strong&gt;resolve the merge conflict&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;open the file with merge conflict in Rstudio editor panel&lt;/li&gt;
&lt;li&gt;decide if you want to keep only your text or the text on GitHub or incorporate changes from both texts&lt;/li&gt;
&lt;li&gt;delete the conflict markers &amp;laquo;&amp;laquo;&amp;laquo;&amp;lt;, =======, &amp;raquo;&amp;raquo;&amp;raquo;&amp;gt; and make the changes you want in the final merge&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For more info on merge conflicts, and if you need to consolidate a document please have a look &lt;a href=&#34;https://happygitwithr.com/&#34;&gt;at this guide&lt;/a&gt; in Particular &lt;a href=&#34;https://happygitwithr.com/pull-tricky.html#git-pull-with-local-commits&#34;&gt;Section 28&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Authenticating with your Github Credentials in R</title>
      <link>/misc/pat-error/</link>
      <pubDate>Mon, 13 Sep 2021 00:00:00 +0000</pubDate>
      <guid>/misc/pat-error/</guid>
      <description>&lt;h2 id=&#34;problem&#34;&gt;Problem&lt;/h2&gt;
&lt;p&gt;In order to interact with GitHub via Rstudio, you need to authenticate yourself. That is, you need to prove you are the owner of your GitHub account. When you log in to GitHub from your browser, you provide your username and password to prove your identity. But when you want to push and pull from your computer, you will need to use a &lt;strong&gt;personal access token (PAT)&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This is how R may try to tell you that it wants to see your PAT:&lt;/p&gt;
&lt;p&gt;&lt;code class=&#34;language-bash hljs&#34;&gt; remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. &lt;br&gt; remote: Please see &lt;a href=&#34;https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/&#34;&gt;https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/&lt;/a&gt; for more information. &lt;br&gt; fatal: unable to access &amp;ldquo;uni-mannheim-qm-2021/week01&amp;hellip;&amp;rdquo; : The requested URL returned error: 403 &lt;/code&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h2 id=&#34;how-to-fix-it&#34;&gt;How to Fix It?&lt;/h2&gt;
&lt;h3 id=&#34;step-1-get-a-pat&#34;&gt;Step 1: Get a PAT&lt;/h3&gt;
&lt;p&gt;Run these lines in the &lt;em&gt;console&lt;/em&gt; (left bottom pane):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;install.packages&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;c&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;usethis&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;credentials&amp;#34;&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;usethis&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;create_github_token&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will open a new page on Github in your browser, where you&amp;rsquo;ll need to select the validity period of your PAT, &lt;strong&gt;Expiration&lt;/strong&gt;. You may want to set it for a longer period of time then 30 days, the default, if you want to deal with this issue less frequently.&lt;/p&gt;
&lt;p&gt;Click on &lt;strong&gt;Generate Token&lt;/strong&gt; at the bottom of the page.&lt;/p&gt;
&lt;p&gt;Next page will give you the PAT. It will be a long string and will look something like this: &lt;code&gt;ghp_Kt33T3rXI1m4a9vxpBU0ngRU0&lt;/code&gt;. Don&amp;rsquo;t close this page yet! You&amp;rsquo;ll need this token, so copy it.&lt;/p&gt;
&lt;h3 id=&#34;step-2-save-aka-cache-it-in-r&#34;&gt;Step 2: Save (a.k.a. cache) it in R&lt;/h3&gt;
&lt;p&gt;Now that you have the PAT, you need to tell it to R. Up until now, it&amp;rsquo;s only there on Github and R does not know your PAT. Here&amp;rsquo;s how you tell the PAT to R:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;install.packages&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;credentials&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;library&lt;/span&gt;(credentials)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;set_github_pat&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Respond to the prompt with your personal access token (PAT).&lt;/p&gt;
&lt;p&gt;If successful, your initial (and subsequent) calls will look like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;set_github_pat&lt;/span&gt;()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# If prompted for GitHub credentials, enter your PAT in the password field&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# Using GITHUB_PAT from Viktoriia Semenova (credential helper: manager-core)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br&gt;
&lt;p&gt;That&amp;rsquo;s it. You should be able to get your Github repo onto your local Rstudio now!&lt;/p&gt;
&lt;h2 id=&#34;pat-update-in-rstudio&#34;&gt;PAT update in RStudio&lt;/h2&gt;
&lt;p&gt;At some point, your PAT will expire and you will need to update it. It&amp;rsquo;s very easy to do.&lt;/p&gt;
&lt;h3 id=&#34;step-1-get-a-pat-1&#34;&gt;Step 1: Get a PAT&lt;/h3&gt;
&lt;p&gt;Follow the same steps as above to generate a new PAT.&lt;/p&gt;
&lt;h3 id=&#34;step-2-save-aka-cache-it-in-r-1&#34;&gt;Step 2: Save (a.k.a. cache) it in R&lt;/h3&gt;
&lt;p&gt;Add the &lt;code&gt;force_new = TRUE&lt;/code&gt; argument to rewrite the stored, expired, PAT.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-r&#34; data-lang=&#34;r&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;credentials&lt;span style=&#34;color:#f92672&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;set_github_pat&lt;/span&gt;(force_new &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;TRUE&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;re done.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
