Browse Source

v1.1.0

main v1.1.0
parent
commit
e0f4c93e82
  1. 2
      DESCRIPTION
  2. 4
      NEWS.md
  3. 4
      cran-comments.md
  4. 2
      docs/404.html
  5. 2
      docs/LICENSE-text.html
  6. 774
      docs/articles/AMR.html
  7. BIN
      docs/articles/AMR_files/figure-html/plot 1-1.png
  8. BIN
      docs/articles/AMR_files/figure-html/plot 3-1.png
  9. BIN
      docs/articles/AMR_files/figure-html/plot 4-1.png
  10. BIN
      docs/articles/AMR_files/figure-html/plot 5-1.png
  11. 85
      docs/articles/EUCAST.html
  12. 163
      docs/articles/MDR.html
  13. 2
      docs/articles/PCA.html
  14. 231
      docs/articles/SPSS.html
  15. 61
      docs/articles/WHONET.html
  16. 320
      docs/articles/benchmarks.html
  17. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png
  18. BIN
      docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png
  19. 2
      docs/articles/index.html
  20. 179
      docs/articles/resistance_predict.html
  21. 2
      docs/authors.html
  22. 2
      docs/index.html
  23. 13
      docs/news/index.html
  24. 2
      docs/pkgdown.yml
  25. 33
      docs/reference/AMR-deprecated.html
  26. 34
      docs/reference/AMR.html
  27. 34
      docs/reference/WHOCC.html
  28. 2
      docs/reference/WHONET.html
  29. 39
      docs/reference/ab_property.html
  30. 37
      docs/reference/age.html
  31. 38
      docs/reference/age_groups.html
  32. 2
      docs/reference/antibiotics.html
  33. 40
      docs/reference/as.ab.html
  34. 38
      docs/reference/as.disk.html
  35. 38
      docs/reference/as.mic.html
  36. 40
      docs/reference/as.mo.html
  37. 39
      docs/reference/as.rsi.html
  38. 37
      docs/reference/atc_online.html
  39. 37
      docs/reference/availability.html
  40. 38
      docs/reference/bug_drug_combinations.html
  41. 36
      docs/reference/catalogue_of_life.html
  42. 37
      docs/reference/catalogue_of_life_version.html
  43. 40
      docs/reference/count.html
  44. 39
      docs/reference/eucast_rules.html
  45. 33
      docs/reference/example_isolates.html
  46. 33
      docs/reference/example_isolates_unclean.html
  47. 33
      docs/reference/extended-functions.html
  48. 35
      docs/reference/filter_ab_class.html
  49. 2
      docs/reference/first_isolate.html
  50. 40
      docs/reference/g.test.html
  51. 2
      docs/reference/ggplot_pca.html
  52. 36
      docs/reference/ggplot_rsi.html
  53. 37
      docs/reference/guess_ab_col.html
  54. 2
      docs/reference/index.html
  55. 36
      docs/reference/join.html
  56. 38
      docs/reference/key_antibiotics.html
  57. 35
      docs/reference/kurtosis.html
  58. 38
      docs/reference/lifecycle.html
  59. 2
      docs/reference/like.html
  60. 40
      docs/reference/mdro.html
  61. 2
      docs/reference/microorganisms.codes.html
  62. 2
      docs/reference/microorganisms.html
  63. 2
      docs/reference/microorganisms.old.html
  64. 39
      docs/reference/mo_property.html
  65. 35
      docs/reference/mo_source.html
  66. 35
      docs/reference/p_symbol.html
  67. 36
      docs/reference/pca.html
  68. 41
      docs/reference/proportion.html
  69. 35
      docs/reference/read.4D.html
  70. 33
      docs/reference/reexports.html
  71. 39
      docs/reference/resistance_predict.html
  72. 2
      docs/reference/rsi_translation.html
  73. 35
      docs/reference/skewness.html
  74. 35
      docs/reference/translate.html
  75. 35
      git_merge.sh
  76. 39
      git_premaster.sh
  77. 33
      git_siteonly.sh

2
DESCRIPTION

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
Package: AMR
Version: 1.0.1.9009
Version: 1.1.0
Date: 2020-04-15
Title: Antimicrobial Resistance Analysis
Authors@R: c(

4
NEWS.md

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
# AMR 1.0.1.9009
## <small>Last updated: 15-Apr-2020</small>
# AMR 1.1.0
### New
* Support for easy principal component analysis for AMR, using the new `pca()` function

4
cran-comments.md

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
# Version 0.10.0
* Although the previous release (1.0.1) is from 2020-02-23, this updates provides support for the upcoming dplyr 1.0.0 which is used (and relied upon) by probably all our users.
* For this specific version, nothing to mention.
* For this specific version, otherwise nothing to mention.
* Since version 0.3.0, CHECK returns a NOTE for having a data directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package.

2
docs/404.html

@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>

2
docs/LICENSE-text.html

@ -81,7 +81,7 @@ @@ -81,7 +81,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>

774
docs/articles/AMR.html

File diff suppressed because it is too large Load Diff

BIN
docs/articles/AMR_files/figure-html/plot 1-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

BIN
docs/articles/AMR_files/figure-html/plot 3-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

BIN
docs/articles/AMR_files/figure-html/plot 4-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

BIN
docs/articles/AMR_files/figure-html/plot 5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

85
docs/articles/EUCAST.html

@ -13,19 +13,20 @@ @@ -13,19 +13,20 @@
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/all.min.css" integrity="sha256-PbSmjxuVAzJ6FPvNYsrXygfGhNJYyZ2GktDbkMBqQZg=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/v4-shims.min.css" integrity="sha256-A6jcAdwFD48VMjlI3GDxUd+eCQa7/KWy6G9oe/ovaPA=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script><meta property="og:title" content="How to apply EUCAST rules">
<meta property="og:description" content="AMR">
<meta property="og:image" content="/logo.svg">
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<body data-spy="scroll" data-target="#toc">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@ -38,7 +39,7 @@ @@ -38,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>
@ -182,12 +183,12 @@ @@ -182,12 +183,12 @@
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>How to apply EUCAST rules</h1>
<h1 data-toc-skip>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">17 March 2020</h4>
<h4 class="date">15 April 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/EUCAST.Rmd"><code>vignettes/EUCAST.Rmd</code></a></small>
<div class="hidden name"><code>EUCAST.Rmd</code></div>
</div>
@ -208,33 +209,33 @@ @@ -208,33 +209,33 @@
<a href="#examples" class="anchor"></a>Examples</h2>
<p>These rules can be used to discard impossible bug-drug combinations in your data. For example, <em>Klebsiella</em> produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of <em>Klebsiella</em> is resistant to ampicillin.</p>
<p>Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, <em>Klebsiella</em>). EUCAST expert rules solve this, that can be used with <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a>oops &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">mo =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"Klebsiella"</span>, </span>
<span id="cb1-2"><a href="#cb1-2"></a> <span class="st">"Escherichia"</span>),</span>
<span id="cb1-3"><a href="#cb1-3"></a> <span class="dt">ampicillin =</span> <span class="st">"S"</span>)</span>
<span id="cb1-4"><a href="#cb1-4"></a>oops</span>
<span id="cb1-5"><a href="#cb1-5"></a><span class="co"># mo ampicillin</span></span>
<span id="cb1-6"><a href="#cb1-6"></a><span class="co"># 1 Klebsiella S</span></span>
<span id="cb1-7"><a href="#cb1-7"></a><span class="co"># 2 Escherichia S</span></span>
<span id="cb1-8"><a href="#cb1-8"></a></span>
<span id="cb1-9"><a href="#cb1-9"></a><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(oops, <span class="dt">info =</span> <span class="ot">FALSE</span>)</span>
<span id="cb1-10"><a href="#cb1-10"></a><span class="co"># mo ampicillin</span></span>
<span id="cb1-11"><a href="#cb1-11"></a><span class="co"># 1 Klebsiella R</span></span>
<span id="cb1-12"><a href="#cb1-12"></a><span class="co"># 2 Escherichia S</span></span></code></pre></div>
<div class="sourceCode" id="cb1"><html><body><pre class="r"><span class="no">oops</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="kw">mo</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"Klebsiella"</span>,
<span class="st">"Escherichia"</span>),
<span class="kw">ampicillin</span> <span class="kw">=</span> <span class="st">"S"</span>)
<span class="no">oops</span>
<span class="co"># mo ampicillin</span>
<span class="co"># 1 Klebsiella S</span>
<span class="co"># 2 Escherichia S</span>
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">oops</span>, <span class="kw">info</span> <span class="kw">=</span> <span class="fl">FALSE</span>)
<span class="co"># mo ampicillin</span>
<span class="co"># 1 Klebsiella R</span>
<span class="co"># 2 Escherichia S</span></pre></body></html></div>
<p>EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called <em>interpretive reading</em> and is part of the <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> function as well:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>data &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">mo =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"Staphylococcus aureus"</span>,</span>
<span id="cb2-2"><a href="#cb2-2"></a> <span class="st">"Enterococcus faecalis"</span>,</span>
<span id="cb2-3"><a href="#cb2-3"></a> <span class="st">"Escherichia coli"</span>,</span>
<span id="cb2-4"><a href="#cb2-4"></a> <span class="st">"Klebsiella pneumoniae"</span>,</span>
<span id="cb2-5"><a href="#cb2-5"></a> <span class="st">"Pseudomonas aeruginosa"</span>),</span>
<span id="cb2-6"><a href="#cb2-6"></a> <span class="dt">VAN =</span> <span class="st">"-"</span>, <span class="co"># Vancomycin</span></span>
<span id="cb2-7"><a href="#cb2-7"></a> <span class="dt">AMX =</span> <span class="st">"-"</span>, <span class="co"># Amoxicillin</span></span>
<span id="cb2-8"><a href="#cb2-8"></a> <span class="dt">COL =</span> <span class="st">"-"</span>, <span class="co"># Colistin</span></span>
<span id="cb2-9"><a href="#cb2-9"></a> <span class="dt">CAZ =</span> <span class="st">"-"</span>, <span class="co"># Ceftazidime</span></span>
<span id="cb2-10"><a href="#cb2-10"></a> <span class="dt">CXM =</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span></span>
<span id="cb2-11"><a href="#cb2-11"></a> <span class="dt">PEN =</span> <span class="st">"S"</span>, <span class="co"># Penicillin G</span></span>
<span id="cb2-12"><a href="#cb2-12"></a> <span class="dt">FOX =</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span></span>
<span id="cb2-13"><a href="#cb2-13"></a> <span class="dt">stringsAsFactors =</span> <span class="ot">FALSE</span>)</span></code></pre></div>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a>data</span></code></pre></div>
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="kw">mo</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"Staphylococcus aureus"</span>,
<span class="st">"Enterococcus faecalis"</span>,
<span class="st">"Escherichia coli"</span>,
<span class="st">"Klebsiella pneumoniae"</span>,
<span class="st">"Pseudomonas aeruginosa"</span>),
<span class="kw">VAN</span> <span class="kw">=</span> <span class="st">"-"</span>, <span class="co"># Vancomycin</span>
<span class="kw">AMX</span> <span class="kw">=</span> <span class="st">"-"</span>, <span class="co"># Amoxicillin</span>
<span class="kw">COL</span> <span class="kw">=</span> <span class="st">"-"</span>, <span class="co"># Colistin</span>
<span class="kw">CAZ</span> <span class="kw">=</span> <span class="st">"-"</span>, <span class="co"># Ceftazidime</span>
<span class="kw">CXM</span> <span class="kw">=</span> <span class="st">"-"</span>, <span class="co"># Cefuroxime</span>
<span class="kw">PEN</span> <span class="kw">=</span> <span class="st">"S"</span>, <span class="co"># Penicillin G</span>
<span class="kw">FOX</span> <span class="kw">=</span> <span class="st">"S"</span>, <span class="co"># Cefoxitin</span>
<span class="kw">stringsAsFactors</span> <span class="kw">=</span> <span class="fl">FALSE</span>)</pre></body></html></div>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="no">data</span></pre></body></html></div>
<table class="table">
<thead><tr class="header">
<th align="left">mo</th>
@ -299,7 +300,7 @@ @@ -299,7 +300,7 @@
</tr>
</tbody>
</table>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(data)</span></code></pre></div>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">data</span>)</pre></body></html></div>
<table class="table">
<thead><tr class="header">
<th align="left">mo</th>
@ -369,15 +370,9 @@ @@ -369,15 +370,9 @@
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<div id="tocnav">
<h2 class="hasAnchor">
<a href="#tocnav" class="anchor"></a>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#introduction">Introduction</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
<nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
</nav>
</div>
</div>
</div>
@ -388,7 +383,7 @@ @@ -388,7 +383,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.9000.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
</div>
</footer>

163
docs/articles/MDR.html

@ -13,19 +13,20 @@ @@ -13,19 +13,20 @@
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/all.min.css" integrity="sha256-PbSmjxuVAzJ6FPvNYsrXygfGhNJYyZ2GktDbkMBqQZg=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/v4-shims.min.css" integrity="sha256-A6jcAdwFD48VMjlI3GDxUd+eCQa7/KWy6G9oe/ovaPA=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script><meta property="og:title" content="How to determine multi-drug resistance (MDR)">
<meta property="og:description" content="AMR">
<meta property="og:image" content="/logo.svg">
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<body data-spy="scroll" data-target="#toc">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@ -38,7 +39,7 @@ @@ -38,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>
@ -182,12 +183,12 @@ @@ -182,12 +183,12 @@
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>How to determine multi-drug resistance (MDR)</h1>
<h1 data-toc-skip>How to determine multi-drug resistance (MDR)</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">17 March 2020</h4>
<h4 class="date">15 April 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/MDR.Rmd"><code>vignettes/MDR.Rmd</code></a></small>
<div class="hidden name"><code>MDR.Rmd</code></div>
</div>
@ -233,15 +234,15 @@ @@ -233,15 +234,15 @@
<a href="#examples" class="anchor"></a>Examples</h4>
<p>The <code><a href="../reference/mdro.html">mdro()</a></code> function always returns an ordered <code>factor</code>. For example, the output of the default guideline by Magiorakos <em>et al.</em> returns a <code>factor</code> with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.</p>
<p>The next example uses the <code>example_isolates</code> data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(dplyr) <span class="co"># to support pipes: %&gt;%</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>example_isolates <span class="op">%&gt;%</span><span class="st"> </span></span>
<span id="cb2-2"><a href="#cb2-2"></a><span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdro</a></span>() <span class="op">%&gt;%</span><span class="st"> </span></span>
<span id="cb2-3"><a href="#cb2-3"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>() <span class="co"># show frequency table of the result</span></span>
<span id="cb2-4"><a href="#cb2-4"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `mo` as input for `col_mo`.</span></span>
<span id="cb2-5"><a href="#cb2-5"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: Auto-guessing columns suitable for analysis...OK.</span></span>
<span id="cb2-6"><a href="#cb2-6"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)</span></span>
<span id="cb2-7"><a href="#cb2-7"></a><span class="co"># Warning in mdro(.): NA introduced for isolates where the available percentage of</span></span>
<span id="cb2-8"><a href="#cb2-8"></a><span class="co"># antimicrobial classes was below 50% (set with `pct_required_classes`)</span></span></code></pre></div>
<div class="sourceCode" id="cb1"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">dplyr</span>) <span class="co"># to support pipes: %&gt;%</span></pre></body></html></div>
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="../reference/mdro.html">mdro</a></span>() <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>() <span class="co"># show frequency table of the result</span>
<span class="co"># NOTE: Using column `mo` as input for `col_mo`.</span>
<span class="co"># NOTE: Auto-guessing columns suitable for analysis...OK.</span>
<span class="co"># NOTE: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)</span>
<span class="co"># Warning in mdro(.): NA introduced for isolates where the available percentage of</span>
<span class="co"># antimicrobial classes was below 50% (set with `pct_required_classes`)</span></pre></body></html></div>
<p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered (numeric)<br>
Length: 2,000<br>
@ -277,55 +278,55 @@ Unique: 2</p> @@ -277,55 +278,55 @@ Unique: 2</p>
</tbody>
</table>
<p>For another example, I will create a data set to determine multi-drug resistant TB:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a><span class="co"># a helper function to get a random vector with values S, I and R</span></span>
<span id="cb3-2"><a href="#cb3-2"></a><span class="co"># with the probabilities 50% - 10% - 40%</span></span>
<span id="cb3-3"><a href="#cb3-3"></a>sample_rsi &lt;-<span class="st"> </span><span class="cf">function</span>() {</span>
<span id="cb3-4"><a href="#cb3-4"></a> <span class="kw"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>(<span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"S"</span>, <span class="st">"I"</span>, <span class="st">"R"</span>),</span>
<span id="cb3-5"><a href="#cb3-5"></a> <span class="dt">size =</span> <span class="dv">5000</span>,</span>
<span id="cb3-6"><a href="#cb3-6"></a> <span class="dt">prob =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="fl">0.5</span>, <span class="fl">0.1</span>, <span class="fl">0.4</span>),</span>
<span id="cb3-7"><a href="#cb3-7"></a> <span class="dt">replace =</span> <span class="ot">TRUE</span>)</span>
<span id="cb3-8"><a href="#cb3-8"></a>}</span>
<span id="cb3-9"><a href="#cb3-9"></a></span>
<span id="cb3-10"><a href="#cb3-10"></a>my_TB_data &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">rifampicin =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-11"><a href="#cb3-11"></a> <span class="dt">isoniazid =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-12"><a href="#cb3-12"></a> <span class="dt">gatifloxacin =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-13"><a href="#cb3-13"></a> <span class="dt">ethambutol =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-14"><a href="#cb3-14"></a> <span class="dt">pyrazinamide =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-15"><a href="#cb3-15"></a> <span class="dt">moxifloxacin =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb3-16"><a href="#cb3-16"></a> <span class="dt">kanamycin =</span> <span class="kw">sample_rsi</span>())</span></code></pre></div>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="co"># a helper function to get a random vector with values S, I and R</span>
<span class="co"># with the probabilities 50% - 10% - 40%</span>
<span class="no">sample_rsi</span> <span class="kw">&lt;-</span> <span class="kw">function</span>() {
<span class="fu"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>(<span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"S"</span>, <span class="st">"I"</span>, <span class="st">"R"</span>),
<span class="kw">size</span> <span class="kw">=</span> <span class="fl">5000</span>,
<span class="kw">prob</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="fl">0.5</span>, <span class="fl">0.1</span>, <span class="fl">0.4</span>),
<span class="kw">replace</span> <span class="kw">=</span> <span class="fl">TRUE</span>)
}
<span class="no">my_TB_data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="kw">rifampicin</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">isoniazid</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">gatifloxacin</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">ethambutol</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">pyrazinamide</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">moxifloxacin</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">kanamycin</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>())</pre></body></html></div>
<p>Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a>my_TB_data &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">RIF =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-2"><a href="#cb4-2"></a> <span class="dt">INH =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-3"><a href="#cb4-3"></a> <span class="dt">GAT =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-4"><a href="#cb4-4"></a> <span class="dt">ETH =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-5"><a href="#cb4-5"></a> <span class="dt">PZA =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-6"><a href="#cb4-6"></a> <span class="dt">MFX =</span> <span class="kw">sample_rsi</span>(),</span>
<span id="cb4-7"><a href="#cb4-7"></a> <span class="dt">KAN =</span> <span class="kw">sample_rsi</span>())</span></code></pre></div>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="no">my_TB_data</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="kw">RIF</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">INH</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">GAT</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">ETH</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">PZA</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">MFX</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>(),
<span class="kw">KAN</span> <span class="kw">=</span> <span class="fu">sample_rsi</span>())</pre></body></html></div>
<p>The data set now looks like this:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1"></a><span class="kw"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(my_TB_data)</span>
<span id="cb5-2"><a href="#cb5-2"></a><span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span></span>
<span id="cb5-3"><a href="#cb5-3"></a><span class="co"># 1 S R R I R R</span></span>
<span id="cb5-4"><a href="#cb5-4"></a><span class="co"># 2 I R R R S R</span></span>
<span id="cb5-5"><a href="#cb5-5"></a><span class="co"># 3 R R R S R S</span></span>
<span id="cb5-6"><a href="#cb5-6"></a><span class="co"># 4 S S R R R S</span></span>
<span id="cb5-7"><a href="#cb5-7"></a><span class="co"># 5 S R S R S S</span></span>
<span id="cb5-8"><a href="#cb5-8"></a><span class="co"># 6 R S S S R S</span></span>
<span id="cb5-9"><a href="#cb5-9"></a><span class="co"># kanamycin</span></span>
<span id="cb5-10"><a href="#cb5-10"></a><span class="co"># 1 S</span></span>
<span id="cb5-11"><a href="#cb5-11"></a><span class="co"># 2 S</span></span>
<span id="cb5-12"><a href="#cb5-12"></a><span class="co"># 3 R</span></span>
<span id="cb5-13"><a href="#cb5-13"></a><span class="co"># 4 R</span></span>
<span id="cb5-14"><a href="#cb5-14"></a><span class="co"># 5 R</span></span>
<span id="cb5-15"><a href="#cb5-15"></a><span class="co"># 6 R</span></span></code></pre></div>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/utils/head.html">head</a></span>(<span class="no">my_TB_data</span>)
<span class="co"># rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin</span>
<span class="co"># 1 S I R R S I</span>
<span class="co"># 2 R S S R S S</span>
<span class="co"># 3 R S S R R I</span>
<span class="co"># 4 I S S R R S</span>
<span class="co"># 5 R R S R I R</span>
<span class="co"># 6 R I S I R S</span>
<span class="co"># kanamycin</span>
<span class="co"># 1 S</span>
<span class="co"># 2 S</span>
<span class="co"># 3 R</span>
<span class="co"># 4 S</span>
<span class="co"># 5 I</span>
<span class="co"># 6 I</span></pre></body></html></div>
<p>We can now add the interpretation of MDR-TB to our data set. You can use:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a><span class="kw"><a href="../reference/mdro.html">mdro</a></span>(my_TB_data, <span class="dt">guideline =</span> <span class="st">"TB"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="fu"><a href="../reference/mdro.html">mdro</a></span>(<span class="no">my_TB_data</span>, <span class="kw">guideline</span> <span class="kw">=</span> <span class="st">"TB"</span>)</pre></body></html></div>
<p>or its shortcut <code><a href="../reference/mdro.html">mdr_tb()</a></code>:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1"></a>my_TB_data<span class="op">$</span>mdr &lt;-<span class="st"> </span><span class="kw"><a href="../reference/mdro.html">mdr_tb</a></span>(my_TB_data)</span>
<span id="cb7-2"><a href="#cb7-2"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span></span>
<span id="cb7-3"><a href="#cb7-3"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: Auto-guessing columns suitable for analysis...OK.</span></span>
<span id="cb7-4"><a href="#cb7-4"></a><span class="co"># </span><span class="al">NOTE</span><span class="co">: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)</span></span></code></pre></div>
<div class="sourceCode" id="cb7"><html><body><pre class="r"><span class="no">my_TB_data</span>$<span class="no">mdr</span> <span class="kw">&lt;-</span> <span class="fu"><a href="../reference/mdro.html">mdr_tb</a></span>(<span class="no">my_TB_data</span>)
<span class="co"># NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.</span>
<span class="co"># NOTE: Auto-guessing columns suitable for analysis...OK.</span>
<span class="co"># NOTE: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)</span></pre></body></html></div>
<p>Create a frequency table of the results:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1"></a><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(my_TB_data<span class="op">$</span>mdr)</span></code></pre></div>
<div class="sourceCode" id="cb8"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(<span class="no">my_TB_data</span>$<span class="no">mdr</span>)</pre></body></html></div>
<p><strong>Frequency table</strong></p>
<p>Class: factor &gt; ordered (numeric)<br>
Length: 5,000<br>
@ -345,40 +346,40 @@ Unique: 5</p> @@ -345,40 +346,40 @@ Unique: 5</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Mono-resistant</td>
<td align="right">3312</td>
<td align="right">66.24%</td>
<td align="right">3312</td>
<td align="right">66.24%</td>
<td align="right">3310</td>
<td align="right">66.20%</td>
<td align="right">3310</td>
<td align="right">66.20%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Negative</td>
<td align="right">634</td>
<td align="right">12.68%</td>
<td align="right">3946</td>
<td align="right">78.92%</td>
<td align="right">637</td>
<td align="right">12.74%</td>
<td align="right">3947</td>
<td align="right">78.94%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Multi-drug-resistant</td>
<td align="right">554</td>
<td align="right">11.08%</td>
<td align="right">4500</td>
<td align="right">90.00%</td>
<td align="right">569</td>
<td align="right">11.38%</td>
<td align="right">4516</td>
<td align="right">90.32%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Poly-resistant</td>
<td align="right">291</td>
<td align="right">5.82%</td>
<td align="right">4791</td>
<td align="right">95.82%</td>
<td align="right">283</td>
<td align="right">5.66%</td>
<td align="right">4799</td>
<td align="right">95.98%</td>
</tr>
<tr class="odd">
<td align="left">5</td>
<td align="left">Extensively drug-resistant</td>
<td align="right">209</td>
<td align="right">4.18%</td>
<td align="right">201</td>
<td align="right">4.02%</td>
<td align="right">5000</td>
<td align="right">100.00%</td>
</tr>
@ -400,7 +401,7 @@ Unique: 5</p> @@ -400,7 +401,7 @@ Unique: 5</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.9000.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
</div>
</footer>

2
docs/articles/PCA.html

@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9009</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>

231
docs/articles/SPSS.html

@ -13,19 +13,20 @@ @@ -13,19 +13,20 @@
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.4.0/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/all.min.css" integrity="sha256-PbSmjxuVAzJ6FPvNYsrXygfGhNJYyZ2GktDbkMBqQZg=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.1/css/v4-shims.min.css" integrity="sha256-A6jcAdwFD48VMjlI3GDxUd+eCQa7/KWy6G9oe/ovaPA=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script><meta property="og:title" content="How to import data from SPSS / SAS / Stata">
<meta property="og:description" content="AMR">
<meta property="og:image" content="/logo.svg">
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<body data-spy="scroll" data-target="#toc">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
@ -38,7 +39,7 @@ @@ -38,7 +39,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.1.0</span>
</span>
</div>
@ -182,12 +183,12 @@ @@ -182,12 +183,12 @@
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header toc-ignore">
<h1>How to import data from SPSS / SAS / Stata</h1>
<h1 data-toc-skip>How to import data from SPSS / SAS / Stata</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">17 March 2020</h4>
<h4 class="date">15 April 2020</h4>
<small class="dont-index">Source: <a href="https://gitlab.com/msberends/AMR/blob/master/vignettes/SPSS.Rmd"><code>vignettes/SPSS.Rmd</code></a></small>
<div class="hidden name"><code>SPSS.Rmd</code></div>
</div>
@ -239,39 +240,38 @@ @@ -239,39 +240,38 @@
</li>
</ul>
<p>To demonstrate the first point:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1"></a><span class="co"># not all values are valid MIC values:</span></span>
<span id="cb1-2"><a href="#cb1-2"></a><span class="kw"><a href="../reference/as.mic.html">as.mic</a></span>(<span class="fl">0.125</span>)</span>
<span id="cb1-3"><a href="#cb1-3"></a><span class="co"># Class 'mic'</span></span>
<span id="cb1-4"><a href="#cb1-4"></a><span class="co"># [1] 0.125</span></span>
<span id="cb1-5"><a href="#cb1-5"></a><span class="kw"><a href="../reference/as.mic.html">as.mic</a></span>(<span class="st">"testvalue"</span>)</span>
<span id="cb1-6"><a href="#cb1-6"></a><span class="co"># Class 'mic'</span></span>
<span id="cb1-7"><a href="#cb1-7"></a><span class="co"># [1] &lt;NA&gt;</span></span>
<span id="cb1-8"><a href="#cb1-8"></a></span>
<span id="cb1-9"><a href="#cb1-9"></a><span class="co"># the Gram stain is avaiable for all bacteria:</span></span>
<span id="cb1-10"><a href="#cb1-10"></a><span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)</span>
<span id="cb1-11"><a href="#cb1-11"></a><span class="co"># [1] "Gram-negative"</span></span>
<span id="cb1-12"><a href="#cb1-12"></a></span>
<span id="cb1-13"><a href="#cb1-13"></a><span class="co"># Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:</span></span>
<span id="cb1-14"><a href="#cb1-14"></a>klebsiella_test &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="dt">mo =</span> <span class="st">"klebsiella"</span>, </span>
<span id="cb1-15"><a href="#cb1-15"></a> <span class="dt">amox =</span> <span class="st">"S"</span>,</span>
<span id="cb1-16"><a href="#cb1-16"></a> <span class="dt">stringsAsFactors =</span> <span class="ot">FALSE</span>)</span>
<span id="cb1-17"><a href="#cb1-17"></a>klebsiella_test <span class="co"># (our original data)</span></span>
<span id="cb1-18"><a href="#cb1-18"></a><span class="co"># mo amox</span></span>
<span id="cb1-19"><a href="#cb1-19"></a><span class="co"># 1 klebsiella S</span></span>
<span id="cb1-20"><a href="#cb1-20"></a><span class="kw"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(klebsiella_test, <span class="dt">info =</span> <span class="ot">FALSE</span>) <span class="co"># (the edited data by EUCAST rules)</span></span>
<span id="cb1-21"><a href="#cb1-21"></a><span class="co"># mo amox</span></span>
<span id="cb1-22"><a href="#cb1-22"></a><span class="co"># 1 klebsiella R</span></span>
<span id="cb1-23"><a href="#cb1-23"></a></span>
<span id="cb1-24"><a href="#cb1-24"></a><span class="co"># hundreds of trade names can be translated to a name, trade name or an ATC code:</span></span>
<span id="cb1-25"><a href="#cb1-25"></a><span class="kw"><a href="../reference/ab_property.html">ab_name</a></span>(<span class="st">"floxapen"</span>)</span>
<span id="cb1-26"><a href="#cb1-26"></a><span class="co"># [1] "Flucloxacillin"</span></span>
<span id="cb1-27"><a href="#cb1-27"></a><span class="kw"><a href="../reference/ab_property.html">ab_tradenames</a></span>(<span class="st">"floxapen"</span>)</span>
<span id="cb1-28"><a href="#cb1-28"></a><span class="co"># [1] "Floxacillin" "FLOXACILLIN" "Floxapen" </span></span>
<span id="cb1-29"><a href="#cb1-29"></a><span class="co"># [4] "Floxapen sodium salt" "Fluclox" "Flucloxacilina" </span></span>
<span id="cb1-30"><a href="#cb1-30"></a><span class="co"># [7] "Flucloxacillin" "Flucloxacilline" "Flucloxacillinum" </span></span>
<span id="cb1-31"><a href="#cb1-31"></a><span class="co"># [10] "Fluorochloroxacillin"</span></span>
<span id="cb1-32"><a href="#cb1-32"></a><span class="kw"><a href="../reference/ab_property.html">ab_atc</a></span>(<span class="st">"floxapen"</span>)</span>
<span id="cb1-33"><a href="#cb1-33"></a><span class="co"># [1] "J01CF05"</span></span></code></pre></div>
<div class="sourceCode" id="cb1"><html><body><pre class="r"><span class="co"># not all values are valid MIC values:</span>
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span>(<span class="fl">0.125</span>)
<span class="co"># Class 'mic'</span>
<span class="co"># [1] 0.125</span>
<span class="fu"><a href="../reference/as.mic.html">as.mic</a></span>(<span class="st">"testvalue"</span>)
<span class="co"># Class 'mic'</span>
<span class="co"># [1] &lt;NA&gt;</span>
<span class="co"># the Gram stain is avaiable for all bacteria:</span>
<span class="fu"><a href="../reference/mo_property.html">mo_gramstain</a></span>(<span class="st">"E. coli"</span>)
<span class="co"># [1] "Gram-negative"</span>
<span class="co"># Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:</span>
<span class="no">klebsiella_test</span> <span class="kw">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span>(<span class="kw">mo</span> <span class="kw">=</span> <span class="st">"klebsiella"</span>,
<span class="kw">amox</span> <span class="kw">=</span> <span class="st">"S"</span>,
<span class="kw">stringsAsFactors</span> <span class="kw">=</span> <span class="fl">FALSE</span>)
<span class="no">klebsiella_test</span> <span class="co"># (our original data)</span>
<span class="co"># mo amox</span>
<span class="co"># 1 klebsiella S</span>
<span class="fu"><a href="../reference/eucast_rules.html">eucast_rules</a></span>(<span class="no">klebsiella_test</span>, <span class="kw">info</span> <span class="kw">=</span> <span class="fl">FALSE</span>) <span class="co"># (the edited data by EUCAST rules)</span>
<span class="co"># mo amox</span>
<span class="co"># 1 klebsiella R</span>
<span class="co"># hundreds of trade names can be translated to a name, trade name or an ATC code:</span>
<span class="fu"><a href="../reference/ab_property.html">ab_name</a></span>(<span class="st">"floxapen"</span>)
<span class="co"># [1] "Flucloxacillin"</span>
<span class="fu"><a href="../reference/ab_property.html">ab_tradenames</a></span>(<span class="st">"floxapen"</span>)
<span class="co"># [1] "floxacillin" "floxapen" "floxapen sodium salt"</span>
<span class="co"># [4] "fluclox" "flucloxacilina" "flucloxacillin" </span>
<span class="co"># [7] "flucloxacilline" "flucloxacillinum" "fluorochloroxacillin"</span>
<span class="fu"><a href="../reference/ab_property.html">ab_atc</a></span>(<span class="st">"floxapen"</span>)
<span class="co"># [1] "J01CF05"</span></pre></body></html></div>
</div>
<div id="import-data-from-spsssasstata" class="section level2">
<h2 class="hasAnchor">
@ -287,97 +287,97 @@ @@ -287,97 +287,97 @@
<p><img src="https://gitlab.com/msberends/AMR/raw/master/docs/import2.png"></p>
<p>If you want named variables to be imported as factors so it resembles SPSS more, use <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>.</p>
<p>The difference is this:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a>SPSS_data</span>
<span id="cb2-2"><a href="#cb2-2"></a><span class="co"># # A tibble: 4,203 x 4</span></span>
<span id="cb2-3"><a href="#cb2-3"></a><span class="co"># v001 sex status statusage</span></span>
<span id="cb2-4"><a href="#cb2-4"></a><span class="co"># &lt;dbl&gt; &lt;dbl+lbl&gt; &lt;dbl+lbl&gt; &lt;dbl&gt;</span></span>
<span id="cb2-5"><a href="#cb2-5"></a><span class="co"># 1 10002 1 1 76.6</span></span>
<span id="cb2-6"><a href="#cb2-6"></a><span class="co"># 2 10004 0 1 59.1</span></span>
<span id="cb2-7"><a href="#cb2-7"></a><span class="co"># 3 10005 1 1 54.5</span></span>
<span id="cb2-8"><a href="#cb2-8"></a><span class="co"># 4 10006 1 1 54.1</span></span>
<span id="cb2-9"><a href="#cb2-9"></a><span class="co"># 5 10007 1 1 57.7</span></span>
<span id="cb2-10"><a href="#cb2-10"></a><span class="co"># 6 10008 1 1 62.8</span></span>
<span id="cb2-11"><a href="#cb2-11"></a><span class="co"># 7 10010 0 1 63.7</span></span>
<span id="cb2-12"><a href="#cb2-12"></a><span class="co"># 8 10011 1 1 73.1</span></span>
<span id="cb2-13"><a href="#cb2-13"></a><span class="co"># 9 10017 1 1 56.7</span></span>
<span id="cb2-14"><a href="#cb2-14"></a><span class="co"># 10 10018 0 1 66.6</span></span>
<span id="cb2-15"><a href="#cb2-15"></a><span class="co"># # … with 4,193 more rows</span></span>
<span id="cb2-16"><a href="#cb2-16"></a></span>
<span id="cb2-17"><a href="#cb2-17"></a><span class="kw">as_factor</span>(SPSS_data)</span>
<span id="cb2-18"><a href="#cb2-18"></a><span class="co"># # A tibble: 4,203 x 4</span></span>
<span id="cb2-19"><a href="#cb2-19"></a><span class="co"># v001 sex status statusage</span></span>
<span id="cb2-20"><a href="#cb2-20"></a><span class="co"># &lt;dbl&gt; &lt;fct&gt; &lt;fct&gt; &lt;dbl&gt;</span></span>
<span id="cb2-21"><a href="#cb2-21"></a><span class="co"># 1 10002 Male alive 76.6</span></span>
<span id="cb2-22"><a href="#cb2-22"></a><span class="co"># 2 10004 Female alive 59.1</span></span>
<span id="cb2-23"><a href="#cb2-23"></a><span class="co"># 3 10005 Male alive 54.5</span></span>
<span id="cb2-24"><a href="#cb2-24"></a><span class="co"># 4 10006 Male alive 54.1</span></span>
<span id="cb2-25"><a href="#cb2-25"></a><span class="co"># 5 10007 Male alive 57.7</span></span>
<span id="cb2-26"><a href="#cb2-26"></a><span class="co"># 6 10008 Male alive 62.8</span></span>
<span id="cb2-27"><a href="#cb2-27"></a><span class="co"># 7 10010 Female alive 63.7</span></span>
<span id="cb2-28"><a href="#cb2-28"></a><span class="co"># 8 10011 Male alive 73.1</span></span>
<span id="cb2-29"><a href="#cb2-29"></a><span class="co"># 9 10017 Male alive 56.7</span></span>
<span id="cb2-30"><a href="#cb2-30"></a><span class="co"># 10 10018 Female alive 66.6</span></span>
<span id="cb2-31"><a href="#cb2-31"></a><span class="co"># # … with 4,193 more rows</span></span></code></pre></div>
<div class="sourceCode" id="cb2"><html><body><pre class="r"><span class="no">SPSS_data</span>
<span class="co"># # A tibble: 4,203 x 4</span>
<span class="co"># v001 sex status statusage</span>
<span class="co"># &lt;dbl&gt; &lt;dbl+lbl&gt; &lt;dbl+lbl&gt; &lt;dbl&gt;</span>
<span class="co"># 1 10002 1 1 76.6</span>
<span class="co"># 2 10004 0 1 59.1</span>
<span class="co"># 3 10005 1 1 54.5</span>
<span class="co"># 4 10006 1 1 54.1</span>
<span class="co"># 5 10007 1 1 57.7</span>
<span class="co"># 6 10008 1 1 62.8</span>
<span class="co"># 7 10010 0 1 63.7</span>
<span class="co"># 8 10011 1 1 73.1</span>
<span class="co"># 9 10017 1 1 56.7</span>
<span class="co"># 10 10018 0 1 66.6</span>
<span class="co"># # … with 4,193 more rows</span>
<span class="fu">as_factor</span>(<span class="no">SPSS_data</span>)
<span class="co"># # A tibble: 4,203 x 4</span>
<span class="co"># v001 sex status statusage</span>
<span class="co"># &lt;dbl&gt; &lt;fct&gt; &lt;fct&gt; &lt;dbl&gt;</span>
<span class="co"># 1 10002 Male alive 76.6</span>
<span class="co"># 2 10004 Female alive 59.1</span>
<span class="co"># 3 10005 Male alive 54.5</span>
<span class="co"># 4 10006 Male alive 54.1</span>
<span class="co"># 5 10007 Male alive 57.7</span>
<span class="co"># 6 10008 Male alive 62.8</span>
<span class="co"># 7 10010 Female alive 63.7</span>
<span class="co"># 8 10011 Male alive 73.1</span>
<span class="co"># 9 10017 Male alive 56.7</span>
<span class="co"># 10 10018 Female alive 66.6</span>
<span class="co"># # … with 4,193 more rows</span></pre></body></html></div>
</div>
<div id="base-r" class="section level3">
<h3 class="hasAnchor">
<a href="#base-r" class="anchor"></a>Base R</h3>
<p>To import data from SPSS, SAS or Stata, you can use the <a href="https://haven.tidyverse.org/">great <code>haven</code> package</a> yourself:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1"></a><span class="co"># download and install the latest version:</span></span>
<span id="cb3-2"><a href="#cb3-2"></a><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"haven"</span>)</span>
<span id="cb3-3"><a href="#cb3-3"></a><span class="co"># load the package you just installed:</span></span>
<span id="cb3-4"><a href="#cb3-4"></a><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(haven) </span></code></pre></div>
<div class="sourceCode" id="cb3"><html><body><pre class="r"><span class="co"># download and install the latest version:</span>
<span class="fu"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"haven"</span>)
<span class="co"># load the package you just installed:</span>
<span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="no">haven</span>)</pre></body></html></div>
<p>You can now import files as follows:</p>
<div id="spss" class="section level4">
<h4 class="hasAnchor">
<a href="#spss" class="anchor"></a>SPSS</h4>
<p>To read files from SPSS into R:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1"></a><span class="co"># read any SPSS file based on file extension (best way):</span></span>
<span id="cb4-2"><a href="#cb4-2"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span>(<span class="dt">file =</span> <span class="st">"path/to/file"</span>)</span>
<span id="cb4-3"><a href="#cb4-3"></a></span>
<span id="cb4-4"><a href="#cb4-4"></a><span class="co"># read .sav or .zsav file:</span></span>
<span id="cb4-5"><a href="#cb4-5"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span>(<span class="dt">file =</span> <span class="st">"path/to/file"</span>)</span>
<span id="cb4-6"><a href="#cb4-6"></a></span>
<span id="cb4-7"><a href="#cb4-7"></a><span class="co"># read .por file:</span></span>
<span id="cb4-8"><a href="#cb4-8"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span>(<span class="dt">file =</span> <span class="st">"path/to/file"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb4"><html><body><pre class="r"><span class="co"># read any SPSS file based on file extension (best way):</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_spss</a></span>(<span class="kw">file</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>)
<span class="co"># read .sav or .zsav file:</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_sav</a></span>(<span class="kw">file</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>)
<span class="co"># read .por file:</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">read_por</a></span>(<span class="kw">file</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>)</pre></body></html></div>
<p>Do not forget about <code><a href="https://haven.tidyverse.org/reference/as_factor.html">as_factor()</a></code>, as mentioned above.</p>
<p>To export your R objects to the SPSS file format:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1"></a><span class="co"># save as .sav file:</span></span>
<span id="cb5-2"><a href="#cb5-2"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span>(<span class="dt">data =</span> yourdata, <span class="dt">path =</span> <span class="st">"path/to/file"</span>)</span>
<span id="cb5-3"><a href="#cb5-3"></a></span>
<span id="cb5-4"><a href="#cb5-4"></a><span class="co"># save as compressed .zsav file:</span></span>
<span id="cb5-5"><a href="#cb5-5"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span>(<span class="dt">data =</span> yourdata, <span class="dt">path =</span> <span class="st">"path/to/file"</span>, <span class="dt">compress =</span> <span class="ot">TRUE</span>)</span></code></pre></div>
<div class="sourceCode" id="cb5"><html><body><pre class="r"><span class="co"># save as .sav file:</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span>(<span class="kw">data</span> <span class="kw">=</span> <span class="no">yourdata</span>, <span class="kw">path</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>)
<span class="co"># save as compressed .zsav file:</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_spss.html">write_sav</a></span>(<span class="kw">data</span> <span class="kw">=</span> <span class="no">yourdata</span>, <span class="kw">path</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>, <span class="kw">compress</span> <span class="kw">=</span> <span class="fl">TRUE</span>)</pre></body></html></div>
</div>
<div id="sas" class="section level4">
<h4 class="hasAnchor">
<a href="#sas" class="anchor"></a>SAS</h4>
<p>To read files from SAS into R:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a><span class="co"># read .sas7bdat + .sas7bcat files:</span></span>
<span id="cb6-2"><a href="#cb6-2"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span>(<span class="dt">data_file =</span> <span class="st">"path/to/file"</span>, <span class="dt">catalog_file =</span> <span class="ot">NULL</span>)</span>
<span id="cb6-3"><a href="#cb6-3"></a></span>
<span id="cb6-4"><a href="#cb6-4"></a><span class="co"># read SAS transport files (version 5 and version 8):</span></span>
<span id="cb6-5"><a href="#cb6-5"></a><span class="kw"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span>(<span class="dt">file =</span> <span class="st">"path/to/file"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb6"><html><body><pre class="r"><span class="co"># read .sas7bdat + .sas7bcat files:</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_sas.html">read_sas</a></span>(<span class="kw">data_file</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>, <span class="kw">catalog_file</span> <span class="kw">=</span> <span class="kw">NULL</span>)
<span class="co"># read SAS transport files (version 5 and version 8):</span>
<span class="fu"><a href="https://haven.tidyverse.org/reference/read_xpt.html">read_xpt</a></span>(<span class="kw">file</span> <span class="kw">=</span> <span class="st">"path/to/file"</span>)</pre></body></html></div>
<p>To export your R objects to the SAS file format:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1"></a><span class="co"># save as regular SAS file:</span></span>