R Views
https://rviews.rstudio.com/
Recent content on R ViewsHugo -- gohugo.ioen-usThu, 25 May 2023 00:00:00 +0000April 2023: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/05/25/april-2023-top-40-new-cran-packages/
Thu, 25 May 2023 00:00:00 +0000https://rviews.rstudio.com/2023/05/25/april-2023-top-40-new-cran-packages/
<p>One hundred fifty-six new packages made it to CRAN in April. Here are my “Top 40” selections in twelve categories: Computational Methods, Data, Ecology, Economics, Genomics, Machine Learning, Mathematics, Medicine, Science, Statistics, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=clarabel">clarabel</a> v0.4.1: Implements <a href="https://oxfordcontrol.github.io/ClarabelDocs/stable/">Clarabel</a>, a versatile interior point solver that solves linear programs, quadratic programs, second-order cone programs, and problems with exponential and power cone constraints. See the <a href="https://cran.r-project.org/web/packages/clarabel/vignettes/clarabel.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=condor">condor</a> v1.0.0: Provides functions to access the <a href="https://htcondor.org/">Condor</a> high performance computing environment. Files are first uploaded to a submitter machine and the resulting job is then passed on to Condor. Look <a href="https://github.com/PacificCommunity/ofp-sam-condor">here</a> for the code.</p>
<p><a href="https://cran.r-project.org/package=GPUmatrix">GPUmatrix</a> v0.1.0: Extends R to use GPUs for matrix computations. See the <a href="https://cran.r-project.org/web/packages/GPUmatrix/vignettes/vignette.html">vignette</a>.</p>
<p><img src="GPUmatrix.png" height = "300" width="500" alt="Plots of computation time for different operations"></p>
<p><a href="https://cran.r-project.org/package=hydroMOPSO">hydroMOPSO</a> v0.1-3: Implements a state-of-the-art <a href="https://en.wikipedia.org/wiki/Particle_swarm_optimization">Multi-Objective Particle Swarm Optimiser (MOPSO)</a>, based on the algorithm developed by <a href="https://ieeexplore.ieee.org/document/7782848">Lin et al. (2018)</a> with improvements described by <a href="https://www.sciencedirect.com/science/article/abs/pii/S1364815213000133?via%3Dihub">Marinao-Rivas & Zambrano-Bigiarini (2020)</a> which can be used for global optimization of non-smooth and non-linear R functions and other models that need to be run from the system console, e.g. <a href="https://swat.tamu.edu/software/plus">SWAT+</a>.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=dataverifyr">dataverifyr</a> v0.1.5: Provides a thin wrapper around <code>dplyr</code>, <code>data.table</code>, <code>arrow</code>, and <code>DBI</code> to allow users to define rules which can be used to verify a given dataset. See <a href="https://cran.r-project.org/web/packages/dataverifyr/readme/README.html">README</a> to get started.</p>
<p><img src="dataverifyr.png" height = "400" width="600" alt="Plot showing verification results"></p>
<p><a href="https://cran.r-project.org/package=neotoma2">neotoma2</a> v1.0.0: Provides functions to access and manipulate data in the <a href="https://api.neotomadb.org/api-docs/">Neotoma Paleoecology Database</a>. See the <a href="https://cran.r-project.org/web/packages/neotoma2/vignettes/neotoma2-package.html">vignette</a>.</p>
<p><img src="neotoma2.svg" height = "500" width="300" alt="Diagram showing file structure for a site"></p>
<p><a href="https://cran.r-project.org/package=rpaleoclim">rpaleoclim</a> v1.0.0: Implements an interface to <a href="http://www.paleoclim.org">PaleoClim</a>, a set of free, high resolution paleoclimate surfaces covering the whole globe that includes data on surface temperature, precipitation and the standard bioclimatic variables commonly used in ecological modelling. See <a href="https://www.nature.com/articles/sdata2017122">Brown et al. (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/rpaleoclim/vignettes/rpaleoclim.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=zctaCrosswalk">zctaCrosswalk</a> v2.0.0: Contains the US Census Bureau’s 2020 ZCTA to County Relationship File, as well as convenience functions to translate between States, Counties and ZIP Code Tabulation Areas (ZCTAs). See the <a href="https://cran.r-project.org/web/packages/zctaCrosswalk/vignettes/a01_introduction.html">Introduction</a> and the vignettes <a href="https://cran.r-project.org/web/packages/zctaCrosswalk/vignettes/a02_workflow-tidycensus.html">Workflow with tidycensus</a>, and <a href="https://cran.r-project.org/web/packages/zctaCrosswalk/vignettes/a03_developer-notes.html">Developer Notes</a>.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=EWSmethods">EWSmethods</a> v1.1.2: Implements methods for forecasting tipping points at the community level that include rolling and expanding window approaches to assessing abundance based early warning signals, non-equilibrium resilience measures, and machine learning. See <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0041010">Dakos et al. (2012)</a>, <a href="https://royalsocietypublishing.org/doi/10.1098/rsos.211475">Deb et al. (2022)</a>, and <a href="https://www.nature.com/articles/nature09389">Drake and Griffen (2010)</a> for background and the <a href="https://cran.r-project.org/web/packages/EWSmethods/vignettes/ews_assessments.html">vignette</a> for an introduction.</p>
<p><img src="EWSmethods.png" height = "300" width="250" alt="Plots of EWS indicators"></p>
<p><a href="https://cran.r-project.org/package=fqacalc">fqacalc</a> v1.0.0: Provides functions for calculating Floristic Quality Assessment (FQA) metrics using regional FQA databases that have been approved or approved with reservations as ecological planning models by the U.S. Army Corps of Engineers (USACE). For information on FQA see <a href="https://esajournals.onlinelibrary.wiley.com/doi/10.1002/ecs2.2825">Spyreas (2019)</a>. There is an <a href="https://cran.r-project.org/web/packages/fqacalc/vignettes/introduction.html">Introduction</a>.</p>
<h3 id="economics">Economics</h3>
<p><a href="https://cran.r-project.org/package=clptheory">clptheory</a> v0.1.0: Provides functions to compute the uniform rate of profit, the vector of price of production and the vector of labor values, and also compute measures of deviation between relative prices of production and relative values. See <a href="https://scholarworks.umass.edu/cgi/viewcontent.cgi?article=1351&context=econ_workingpaper">Basu and Moraltis (2023)</a> for background and <a href="https://cran.r-project.org/web/packages/clptheory/readme/README.html">README</a> for an introduction.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=BREADR">BREADR</a> v1.0.1: Implements a method for estimating degrees of relatedness for extreme low-coverage genotype data and includes functions to quantify and visualize the level of confidence in the estimated degrees of relatedness. See <a href="https://tinyurl.com/29t6gbbx">Rohrlach et al. (2023)</a> for package details and <a href="https://cran.r-project.org/web/packages/BREADR/readme/README.html">README</a> for examples.</p>
<p><img src="BREADR.png" height = "350" width="550" alt="Plots showing degrees of relatedness"></p>
<p><a href="https://cran.r-project.org/package=crosshap">crosshap</a> v1.2.2: Implements a local haplotyping visualization toolbox to capture major patterns of co-inheritance between clusters of linked variants, while connecting findings to phenotypic and demographic traits across individuals. See <a href="https://link.springer.com/article/10.1007/s00122-022-04045-8">Marsh et al. (2022)</a> for a detailed example and <a href="https://cran.r-project.org/web/packages/crosshap/readme/README.html">README</a> for an introduction.</p>
<p><img src="crosshap.jpeg" height = "400" width="400" alt="Visualization of haplotypes by marker groups"></p>
<p><a href="https://cran.r-project.org/package=DAISIEprep">DAISIEprep</a> v0.3.2: Extracts colonization and branching times of island species for analysis with the <code>DAISIE</code> package. There is a <a href="https://cran.r-project.org/web/packages/DAISIEprep/vignettes/Tutorial.html">Tutorial</a> and there are vignettes on <a href="https://cran.r-project.org/web/packages/DAISIEprep/vignettes/Performance.html">Performance</a> and <a href="https://cran.r-project.org/web/packages/DAISIEprep/vignettes/Sensitivity.html">Sensitivity</a>.</p>
<p><img src="DAISIEprep.png" height = height = "500" width="600" alt="Endemicity status of Galápagos genus Cocccyzus"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=CCMMR">CCMMR</a> v0.1: Implements the convex clustering through majorization-minimization algorithm described in <a href="https://arxiv.org/abs/2211.01877">Touw, Groenen, and Terada (2022)</a> to minimize the convex clustering loss function. See <a href="https://cran.r-project.org/web/packages/CCMMR/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=rcccd">rcccd</a> v0.3.2: Provides functions to fit class cover catch digraph classification models. Methods are explained in <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167715201001298?via%3Dihub">Priebe et al. (2001)</a>, <a href="https://link.springer.com/article/10.1007/s00357-003-0003-7">Priebe et al. (2003)</a>, and <a href="https://arxiv.org/abs/1904.04564">Manukyan and Ceyhan (2016)</a>. <a href="https://cran.r-project.org/web/packages/rcccd/readme/README.html">README</a> contains some description.</p>
<p><a href="https://cran.r-project.org/package=TheOpenAIR">TheOpenAir</a> v0.1.0: Implements a wrapper using the <a href="https://platform.openai.com/docs/api-reference">OpenAI API</a> as a back end to integrate <code>ChatGPT</code>into diverse data-related tasks, such as data cleansing and automating analytics scripts. See <a href="https://cran.r-project.org/web/packages/TheOpenAIR/readme/README.html">README</a> to get started.</p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=cyclotomic">cyclotomic</a> v1.1.0: Implements algorithms from the <a href="https://www.gap-system.org/">GAP project</a> to work with cyclotomic numbers: complex numbers that can be thought of as the rational numbers extended with the roots of unity. They have applications in number theory, algebraic geometry, algebraic number theory, coding theory, in the theory of graphs and combinatorics, and in the theory of modular functions and modular curves. See <a href="https://cran.r-project.org/web/packages/cyclotomic/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=markovmix">markovmix</a> v0.1.1: Provides functions to fit a mixture of Markov chains of higher orders from multiple sequences along with various utility functions to derive transition patterns, transition probabilities per component and component priors. See <a href="https://cran.r-project.org/package=markovmix">README</a> for examples.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=DiDforBigData">DiDforBigData</a> v1.0: Provides a big-data-friendly and memory-efficient difference-in-differences estimator for staggered (and non-staggered) treatment contexts. See the <a href="https://cran.r-project.org/web/packages/DiDforBigData/vignettes/DiDforBigData.html">Get Started</a> Guide the vignettes <a href="https://cran.r-project.org/web/packages/DiDforBigData/vignettes/Background.html">Background</a>, <a href="https://cran.r-project.org/web/packages/DiDforBigData/vignettes/Examples.html">Examples</a>, and <a href="https://cran.r-project.org/web/packages/DiDforBigData/vignettes/Theory.html">Theory</a>.</p>
<p><img src="DiD.png" height = "350" width="550" alt="Run time measurements"></p>
<p><a href="https://cran.r-project.org/package=predictNMB">predictNNB</a> v0.1.0: Provides tools to estimate when and where a model-guided treatment strategy may outperform a treat-all or treat-none approach using Monte Carlo simulation and evaluation of the Net Monetary Benefit. See <a href="https://joss.theoj.org/papers/10.21105/joss.05328">Parsons et al. (2023)</a> for details, the <a href="https://cran.r-project.org/web/packages/predictNMB/vignettes/predictNMB.html">Introduction</a>, and the vignettes on <a href="https://cran.r-project.org/web/packages/predictNMB/vignettes/creating-nmb-functions.html">creating functions</a>, <a href="https://cran.r-project.org/web/packages/predictNMB/vignettes/summarising-results-with-predictNMB.html">summarising results</a>, and <a href="https://cran.r-project.org/web/packages/predictNMB/vignettes/detailed-example.html">detailed example</a>.</p>
<p><img src="predictNMB.png" height = "350" width="550" alt="Plot of Net Monetary Benefit by model AUC"></p>
<p><a href="https://cran.r-project.org/package=predRupdate">predRupdate</a> v0.1.0: Provides functions to evaluate the predictive performance of existing clinical prediction model given a new dataset. <a href="https://journals.sagepub.com/doi/10.1177/0962280215626466">See Su et al. (2018)</a>, <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.6080">Debray et al. (2014)</a>, and <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.7586">Martin et al. (2018)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/predRupdate/vignettes/predRupdate.html">Introduction</a> and <a href="https://cran.r-project.org/web/packages/predRupdate/vignettes/predRupdate_technical.html">Technical Background</a>.</p>
<p><a href="https://cran.r-project.org/package=SPARRAfairness">SPARRAfairness</a> v0.0.0.1: Provides functions to analyse the behavior and performance of the Scottish Patients At Risk of admission and Re-Admission risk score which estimates yearly risk of emergency hospital admission using electronic health records for most of the Scottish population. Analysis focuses on differential performance over demographically-defined groups. See the <a href="https://cran.r-project.org/web/packages/SPARRAfairness/vignettes/SPARRAfairness_example.html">vignette</a>.</p>
<p><img src="SPARRA.png" height = "500" width="400" alt="Plot of Adjusted false admission rates"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=kronos">kronos</a> v1.0.0: Implements a framework to analyse circadian or otherwise rhythmic data using the familiar R linear modelling syntax, while taking care of the trigonometry under the hood. Look <a href="https://github.com/thomazbastiaanssen/kronos">here</a> for examples.</p>
<p><img src="kronos.png" height = "300" width="500" alt="Plot of circadian rhythms"></p>
<p><a href="https://cran.r-project.org/package=mpmsim">mpmsim</a> v1.0.0: Provides functions to to simulate matrix population models with particular characteristics based on aspects of life history such as mortality trajectories and fertility trajectories, and allows the exploration of sampling error due to small sample size. See the vignettes on <a href="https://cran.r-project.org/web/packages/mpmsim/vignettes/age_from_stage.html">robustness</a>, <a href="https://cran.r-project.org/web/packages/mpmsim/vignettes/error_propagation.html">sampling error & propagation</a>, and <a href="https://cran.r-project.org/web/packages/mpmsim/vignettes/pca.html">PCA</a>.</p>
<p><img src="mpmsim.png" height = "300" width="500" alt="Plot showing PCA loadings"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=BGFD">BGFD</a> v0.1: Implements the probability density function, cumulative distribution function, quantile function, random numbers, survival function, hazard rate function, and maximum likelihood estimates for the family of Bell-G and Complementary Bell-G distributions. See
<a href="https://www.hindawi.com/journals/cin/2022/2489998/">Fayomi et al. (2022)</a>, <a href="http://www.aimspress.com/article/doi/10.3934/math.2023352">Alanzi et al.(2023)</a>, and <a href="https://www.mdpi.com/2075-1680/11/9/438">Algarni (2022)</a> for details.</p>
<p><a href="https://cran.r-project.org/package=D3mirt">D3mirt</a> v1.0.3: Provides functions for identifying, estimating, and plotting descriptive multidimensional item response theory models, restricted to 3D and dichotomous or polytomous data that fit the two-parameter logistic model or the graded response model. See
the <a href="https://cran.r-project.org/web/packages/D3mirt/vignettes/Intro_to_D3mirt.html">vignette</a> for an extensive introduction.</p>
<p><img src="D3mirt.png" height = "300" width="450" alt="Data plotted in vector space"></p>
<p><a href="https://cran.r-project.org/package=funStatTest">funStatTest</a> v1.0.2: Implements two sample comparison procedures based on median-based statistical tests for functional data, described in <a href="https://www.tandfonline.com/doi/abs/10.1080/10485252.2022.2064997?journalCode=gnst20">Smida et al. (2022)</a>, <a href="https://academic.oup.com/biomet/article-abstract/102/1/239/229449?redirectedFrom=fulltext&login=false">Chakraborty and Chaudhuri (2015)</a>, <a href="https://academic.oup.com/jrsssb/article/75/1/103/7075406?login=false">Horvath et al. (2013</a>, and <a href="https://www.sciencedirect.com/science/article/abs/pii/S016794730300269X?via%3Dihub">Cuevas et al. (2004)</a>. See the <a href="https://cran.r-project.org/web/packages/funStatTest/vignettes/getting-started-with-functional-statistical-testing.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=lessSEM">lessSEM</a> v1.4.16: Provides regularized structural equation modeling (regularized SEM) with non-smooth penalty functions (e.g., lasso) building on <code>lavaan</code>. There are nine vignettes including: <a href="https://cran.r-project.org/web/packages/lessSEM/vignettes/lessSEM.html">lessSEM</a>, <a href="https://cran.r-project.org/web/packages/lessSEM/vignettes/The-Structural-Equation-Model.html">The Structural Equation Model</a>, and <a href="https://cran.r-project.org/web/packages/lessSEM/vignettes/Mixed-Penalties.html">Mixed Penalties</a>.</p>
<p><img src="lessSEM.png" height = "500" width="300" alt="Plot of regularized parameters: value vs lambda"></p>
<p><a href="https://cran.r-project.org/package=panelhetero">panelhetero</a> v1.0.0: Provides tools for estimating the degree of heterogeneity across cross-sectional units in the panel data analysis using the methods developed by <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304407619301022?via%3Dihub">Okui and Yanagi (2019)</a> and <a href="https://academic.oup.com/ectj/article-abstract/23/1/156/5607791?redirectedFrom=fulltext&login=false">Okui and Yanagi (2020)</a>. See the <a href="https://cran.r-project.org/web/packages/panelhetero/vignettes/panelhetero.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=tdsa">tdsa</a> v1.0-1: Provides functions to perform time-dependent sensitivity analysis by calculating time-dependent state and parameter sensitivities for both continuous- and discrete-time deterministic models. See <a href="https://www.biorxiv.org/content/10.1101/2023.04.13.536769v1">Ng et al. (in review)</a> for background and the <a href="https://cran.r-project.org/web/packages/tdsa/vignettes/demo.html">vignette</a> to get started.</p>
<p><img src="tdsa.png" height = "600" width="400" alt="Plot of parameter sensitivities over time"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=crew.cluster">crew.cluster</a> v0.1.0: Extends the <code>mirai</code>-powered <code>crew</code> package with worker launcher plugins for traditional high-performance computing systems to enable statisticians and data scientists to asynchronously deploy long-running tasks to distributed systems, ranging from traditional clusters to cloud services. Look <a href="https://github.com/wlandau/crew.cluster">here</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=duke">duke</a> v0.0.1: Provides functions to generate visualizations with Duke’s official suite of colors in a color blind friendly way. There is an <a href="https://cran.r-project.org/web/packages/duke/vignettes/duke.html">Overview</a> and four additional vignettes including one on the <a href="https://cran.r-project.org/web/packages/duke/vignettes/theme_duke_vignette.html">theme_duke()</a> function.</p>
<p><img src="duke.png" height = "600" width="400" alt="Plot showing colors and theme"></p>
<p><a href="https://cran.r-project.org/package=grateful">grateful</a> v0.2.0: Facilitates the citation of R packages used in analysis projects by providing functions to scan projects for packages used and produces documents with citations in the preferred bibliography format. Functions may be used within <code>rarkdown</code>or <code>quarto</code> documents. See <a href="https://cran.r-project.org/web/packages/grateful/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=hightR">hightR</a> v0.3.0: Implements the <a href="https://www.iacr.org/archive/ches2006/04/04.pdf">HIGHT</a> block cipher encryption algorithm developed to provide confidentiality in low power consumption computing environments such Radio-Frequency Identification and Ubiquitous Sensor Network. Look <a href="https://github.com/Yongwoo-Eg-Kim/hightR">here</a> for more information.</p>
<p><a href="https://cran.r-project.org/package=myCRAN">myCRAN</a> v1.0: Provides functions to plot the daily and cumulative number of downloads of <code>R</code> packages, obtaining daily and cumulative counts in one run. See the <a href="https://cran.r-project.org/web/packages/myCRAN/vignettes/myCRAN.html">vignette</a>.</p>
<p><img src="myCRAN.jpeg" height = "400" width="600" alt="Plot package downloads"></p>
<p><a href="https://cran.r-project.org/package=woodendesc">woodendesc</a> v0.1.0: Provides functions to simplify obtaining available packages, their version codes and dependencies from any <code>R</code> repository. Uses extensive caching for repeated queries. See <a href="https://cran.r-project.org/web/packages/woodendesc/readme/README.html">README</a>for examples.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=fxl">fxl</a> v1.6.3: Provides functions to prepare and design <a href="https://sites.hofstra.edu/jeffrey-froh/wp-content/uploads/sites/86/2019/11/Single-Case.pdf">single case design</a> figures that are typically prepared in spreadsheet software. See the <a href="https://cran.r-project.org/web/packages/fxl/vignettes/fxl.html">vignette</a> for theory and examples.</p>
<p><img src="fxl.png" height = "400" width="600" alt="Plot of hybrid design that combines multiple baselines"></p>
<p><a href="https://cran.r-project.org/package=ggragged">ggragged</a> v0.1.0: Extends <code>ggplot2</code> facets to panel layouts arranged in a grid with ragged edges with rows and columns of potentially varying lengths. These may be useful in representing nested or partially crossed relationships between faceting variables. See <a href="https://cran.r-project.org/web/packages/ggragged/readme/README.html">README</a> for examples.</p>
<p><img src="ggragged.png" height = "400" width="600" alt="Grid with different number of plots on each row"></p>
<p><a href="https://cran.r-project.org/package=nndiagram">nndiagram</a> v1.0.0: Generates <code>LaTeX</code> code for drawing well-formatted neural network diagrams with <a href="https://www.overleaf.com/learn/latex/TikZ_package"><code>TikZ</code></a>. Users define the number of neurons on each layer, neuron connections to keep or omit, layers considered to be oversized, and neurons to draw with lighter color. See <a href="https://cran.r-project.org/web/packages/nndiagram/readme/README.html">README</a> for instructions.</p>
<p><img src="nndiagram.png" height = "400" width="600" alt="Neural network diagram"></p>
<p><a href="https://cran.r-project.org/package=PlotTools">PlotTools</a> v0.2.0: Provides functions to manipulate irregular polygons and annotate plots with legends for continuous variables and color spectra using the base graphics plotting tools. See <a href="https://cran.r-project.org/web/packages/PlotTools/readme/README.html">README</a> for an example.</p>
<p><img src="PlotTools.png" height = "400" width="500" alt="Scatter plot with varying size plot symbols"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/05/25/april-2023-top-40-new-cran-packages/';</script>
March 2023: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/04/28/march-2023-top-40-new-cran-packages/
Fri, 28 Apr 2023 00:00:00 +0000https://rviews.rstudio.com/2023/04/28/march-2023-top-40-new-cran-packages/
<h3 id="accounting">Accounting</h3>
<p><a href="https://cran.r-project.org/package=debkeepr">debkeepr</a> v0.1.1: Provides tools to analyze historical, non-decimal currencies and value systems that use tripartite or tetrapartite systems such as pounds and shillings in the context of double-entry bookkeeping. See the <a href="https://cran.r-project.org/web/packages/debkeepr/vignettes/debkeepr.html">Getting Started</a> guide and the vignettes <a href="https://cran.r-project.org/web/packages/debkeepr/vignettes/ledger.html">Analysis of Richard Dafforne’s Journal and Ledger</a> and <a href="https://cran.r-project.org/web/packages/debkeepr/vignettes/transactions.html">Transactions in Richard Dafforne’s Journal</a>.</p>
<p><img src="debkeeper.png" height = "400" width="600" alt="Plot showing whether the original data is recovered by the dSVD"></p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://CRAN.R-project.org/package=ABM">ABM</a> v0.3: Implements a high-performance, flexible and extensible framework to develop continuous-time agent based models capable of simulating millions of agents in which state transitions may be either spontaneous or caused by agent interactions. See <a href="https://cran.r-project.org/web/packages/ABM/readme/README.html">README</a> for multiple examples including <a href="https://github.com/junlingm/ABM/wiki/Agent-SEIR">Simulate an agent based SEIR model</a> and <a href="https://github.com/junlingm/ABM/wiki/Contact-Tracing-SIR">Simulate contact tracing on an SIR model</a>.</p>
<p><a href="https://cran.r-project.org/package=rvMF">rvMF</a> v0.0.7: Provides functions to generate pseudo-random vectors that follow an arbitrary von Mises-Fisher distribution on a sphere including functions to generate random variates, compute the density for the distribution of an inner product between von Mises-Fisher random vector and its mean direction. Look <a href="https://github.com/seungwoo-stat/rvMF">here</a> for an example.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=FertNet">FertNet</a> v0.1.1: Provides tools to processes data from <a href="https://dataarchive.lissdata.nl/">The Social Networks and Fertility Survey</a> including functions for correcting respondent errors and for transforming network data into network objects to facilitate analyses and visualization. See <a href="https://cran.r-project.org/web/packages/FertNet/readme/README.html">README</a> to get started.</p>
<p><img src="FertNet.png" height = "400" width="600" alt="Visualization of a network for one of the respondents"></p>
<p><a href="https://cran.r-project.org/package=oldbailey">oldbailey</a> v1.0.0: Provides functions to fetch trial data from the <a href="https://www.oldbaileyonline.org/static/DocAPI.jsp">Old Bailey Online API</a>. Data includes the names of the first person speakers, defendants, victims, their recorded genders, verdicts, punishments, crime locations, and dates. Look <a href="https://github.com/rOpenGov/oldbailey">here</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=webtrackR">webtrackR</a> v0.0.1: Implements data structures and methods to work with web tracking data, including data preprocessing steps, methods to construct audience networks as described in <a href="https://www.tandfonline.com/doi/abs/10.1080/19312458.2020.1724274?journalCode=hcms20">Mangold & Scharkow (2020)</a> and metrics of news audience polarization described in <a href="https://doi.org/10.1080%2F19312458.2022.2085249">Mangold & Scharkow (2022)</a>. Look <a href="https://github.com/schochastics/webtrackR">here</a> to get started.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=GIFT">GIFT</a> v1.0.0: Provides functions to retrieve regional plant checklists, species traits and distributions, and environmental data from the <a href="https://gift.uni-goettingen.de/about">Global Inventory of Floras and Traits</a> database and to visualize the map of available flora. There is an introductory <a href="https://cran.r-project.org/web/packages/GIFT/vignettes/GIFT.html">Tutorial</a>, an <a href="https://cran.r-project.org/web/packages/GIFT/vignettes/GIFT_advanced_users.html">Advanced Tutorial</a>, and a vignette on <a href="https://cran.r-project.org/web/packages/GIFT/vignettes/GIFT_API.html">Queries</a>.</p>
<p><img src="GIFT.png" height = "400" width="600" alt="Projection map of angiosperms"></p>
<p><a href="https://cran.r-project.org/package=rTLsDeep">rTLsDeep</a> v0.0.5: Uses <a href="https://www.sciencedirect.com/topics/earth-and-planetary-sciences/terrestrial-laser-scanning">terrestrial laser scanning</a> and deep learning to classify post-hurricane damage severity at the individual tree level. See <a href="https://www.mdpi.com/2072-4292/15/4/1165">Klauberg et al. (2023)</a> for details, and look <a href="https://github.com/carlos-alberto-silva/rTLsDeep">here</a> for an example.</p>
<p><img src="rTLsDeep.gif" height = "500" width="300" alt="3D Tree Scan"></p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=HDRFA">HSRFA</a> v0.1.1: Implements two algorithms to do robust factor analysis by considering the Huber loss: one is based on minimizing the Huber loss of the idiosyncratic error’s L2 norm, the other is based on minimizing the element-wise Huber loss. See <a href="https://arxiv.org/abs/2303.02817">He et al. (2023)</a> for background, <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/1468-0262.00392">Bai (2003)</a> for PCA code, and <a href="https://www.tandfonline.com/doi/abs/10.1080/07350015.2020.1811101?journalCode=ubes20">He et al. (2022)</a>, and <a href="https://www.econometricsociety.org/publications/econometrica/2021/03/01/quantile-factor-models">Chen et al. (2021)</a> for the Quantile Factor Analysis method.</p>
<p><a href="https://cran.r-project.org/package=PCRA">PCRA</a> v1.0: Provides a collection of functions and several real-world data sets that support teaching a quantitative finance MS level course on Portfolio Construction and Risk Analysis. See the vignette: <a href="https://cran.r-project.org/web/packages/PCRA/vignettes/PCRAVignette.pdf">Introduction to CRSP Stocks and SPGMI Factors in PCRA</a>.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=GeSciLiVis">GESciLiVis</a> v1.1.0: Provides tools to visualize publication activity per gene based on a gene list and a user-defined set of keywords to perform an <a href="https://www.ncbi.nlm.nih.gov">NCBI</a> database search as in <a href="https://pubmed.ncbi.nlm.nih.gov">PubMed</a>. See the <a href="https://cran.r-project.org/web/packages/GeSciLiVis/vignettes/Getting_started_with_GeSciLiVis.html">vignette</a>.</p>
<p><img src="GESci.png" height = "400" width="600" alt="Bar plot of results from search of human gene set"></p>
<p><a href="https://cran.r-project.org/package=ggpicrust2">ggpicrust2</a> v1.6.0: Provides tools to analyze and visualize <a href="https://www.nature.com/articles/s41587-020-0548-6">PICRUSt2</a> output with pre-defined plots and functions, including a one-click option for creating publication-level plots. For more details, see <a href="https://arxiv.org/abs/2303.10388">Yang et al. (2023)</a>. Look <a href="https://github.com/cafferychen777/ggpicrust2">here</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=gsdensity">gsdensity</a> v0.1.2: Implements a computational tool for pathway centric analysis of single-cell data including scRNA-seq data and spatial genomics data. Given a gene set and a cell-by-gene matrix, ask the question: is this gene set somehow enriched by a subpopulation of the cells? See <a href="https://cran.r-project.org/web/packages/gsdensity/readme/README.html">README</a> for examples.</p>
<p><img src="gsdensity.png" height = "500" width="600" alt="Seurat annotations on UMAP vs UMAP plot"></p>
<p><a href="https://cran.r-project.org/package=metaGE">metaGE</a> v1.0.0: Provides tools for conducting genome-wide association studies for studying Genotype x Environment interactions, including functions to collect the results of GWAS data from different files, infer the inter-environment correlation matrix, perform global test procedure for quantitative trait loci detection, and perform tests of contrast or meta-regression. See <a href="https://www.biorxiv.org/content/10.1101/2023.03.01.530237v1.full.pdf">De Walsche et al. (2023)</a> for the details.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=FACT">FACT</a> v0.1.0: Implements an algorithm agnostic framework for feature attribution while preserving the integrity of the data and facilitating the understand of the mapping procedure of an algorithm that assigns instances to clusters. See <a href="https://cran.r-project.org/web/packages/FACT/readme/README.html">README</a> to get started.</p>
<p><img src="FACT.png" height = "400" width="600" alt="Density plots for three clusters"></p>
<p><a href="https://cran.r-project.org/package=lpda">lpda</a> v1.0.1: Implements the linear programming classification method described by <a href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0270403">Nueda, et al. (2022)</a> which is advantageous when variable distributions are unknown or when the number of variables is much greater than the number of observations. See the <a href="https://cran.r-project.org/web/packages/lpda/vignettes/lpdaUsersGuide.html">vignette</a>.</p>
<p><img src="lpda.png" height = "400" width="600" alt="Plot showing the separating hyperplane">
<a href="https://cran.r-project.org/package=UBayFS">UBayFS</a> v1.0: Implements the user-guided Bayesian framework proposed by <a href="https://link.springer.com/article/10.1007/s10994-022-06221-9">Jenul et al. (2022)</a> for ensemble feature selection. See the <a href="https://cran.r-project.org/web/packages/UBayFS/vignettes/UBayFS.html">Introduction</a> and the vignette on <a href="https://cran.r-project.org/web/packages/UBayFS/vignettes/BFS_UBayFS.html">Block feature selection</a>.</p>
<p><img src="UBayFS.png" height = "400" width="600" alt="Plot showing features and constraints"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=qfratio">qfratio</a> v1.0.1: Provides functions to evaluate moments of ratios and products of quadratic forms in normal variables using recursive algorithms developed by <a href="https://www.sciencedirect.com/science/article/pii/S0047259X13000298?via%3Dihub">Bao and Kan (2013)</a> and and <a href="https://www.cambridge.org/core/journals/econometric-theory/article/abs/generating-functions-and-short-recursions-with-applications-to-the-moments-of-quadratic-forms-in-noncentral-normal-vectors/A07153FA541311DE561BCCBAC2B26984">Hillier et al. (2014)</a>. See <a href="https://cran.r-project.org/web/packages/qfratio/readme/README.html">README</a> for examples.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=gsDesign2">gsDesign2</a> v1.0.7: Provides tools to enable fixed or group sequential design under non-proportional hazards assumptions that support flexible enrollment, time-to-event and time-to-dropout assumptions. Design methods include average hazard ratio, the weighted logrank tests in <a href="https://onlinelibrary.wiley.com/doi/10.1111/biom.13196">Yung and Liu (2019)</a>, and MaxCombo tests. See the <a href="https://cran.r-project.org/web/packages/gsDesign2/vignettes/gsDesign2.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=NCC">NCC</a> v1.0: Provides functions to simulate and analyze platform trials with non-concurrent controls. See <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-022-01683-w">Bofill Roig et al. (2022)</a>, <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-022-01683-w">Saville et al. (2022)</a>, and <a href="https://onlinelibrary.wiley.com/doi/10.1111/biom.12242">Schmidli et al. (2014)</a> for background. There is a brief <a href="https://cran.r-project.org/web/packages/NCC/vignettes/ncc_intro.html">Introduction</a> and there are vignettes on simulating <a href="https://cran.r-project.org/web/packages/NCC/vignettes/datasim_bin.html">binary</a> data, <a href="https://cran.r-project.org/web/packages/NCC/vignettes/datasim_cont.html">continuous</a> data, and <a href="https://cran.r-project.org/web/packages/NCC/vignettes/how_to_run_sim_study.html">How to run a simulation study</a>.</p>
<p><img src="NCC.gif" height = "400" width="600" alt="For treatments that enter the trial later, the control group is divided into concurrent (CC) and non-concurrent controls (NCC)"></p>
<h3 id="pharma">Pharma</h3>
<p><a href="https://cran.r-project.org/package=DrugExposureDiagnostics">DrugExposureDiagnostics</a> v0.4.1: Provides ingredient specific diagnostics for drug exposure records in the Observational Medical Outcomes Partnership <a href="https://www.ohdsi.org/data-standardization/">(OMOP) common data model</a>. See the <a href="https://cran.r-project.org/web/packages/DrugExposureDiagnostics/vignettes/Introduction_to_DrugExposureDiagnostics.html">Introduction</a> and the <a href="https://cran.r-project.org/web/packages/DrugExposureDiagnostics/vignettes/Summary_of_checks.html">Summary of checks</a> vignette.</p>
<p><a href="https://cran.r-project.org/package=rlistings">rlistings</a> v0.1.1: Provides functions to create and display listings for clinical trials. See the <a href="https://cran.r-project.org/web/packages/rlistings/vignettes/rlistings.html">Getting Started Guide</a>.</p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=LCMSQA">LCMSQA</a> v1.0.0: Provides functions to check the quality of liquid chromatograph/mass spectrometry (LC/MS) experiments using an interactive <code>shiny</code> application. Tests include total ion current chromatogram, base peak chromatogram, mass spectrum, and extracted ion chromatogram. See the <a href="https://cran.r-project.org/web/packages/LCMSQA/vignettes/LCMSQA.html">Introduction</a>.</p>
<p><img src="LCMSQA.png" height = "400" width="600" alt="Feature detection screen"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=lmw">lmw</a> v0.0.1: Provides functions to compute the implied weights of linear regression models for estimating average causal effects and provides diagnostics based on these weights. See <a href="https://academic.oup.com/biomet/advance-article-abstract/doi/10.1093/biomet/asac058/6779968?redirectedFrom=fulltext&login=false">Chattopadhyay and Zubizarreta (2022)</a> where several regression estimators are represented as weighting estimators, in connection with inverse probability weighting. Look <a href="https://github.com/ngreifer/lm">here</a> for examples.</p>
<p><img src="lmw.png" height = "400" width="600" alt="Plot of sample influence curve"></p>
<p><a href="https://cran.r-project.org/package=ptable">ptable</a> v1.0.0: Implements the cell-key statistical disclosure control perturbation technique to protect confidential information. See <a href="https://link.springer.com/chapter/10.1007/978-3-319-45381-1_18">Giessing (2016)</a> for the technical details and the <a href="https://cran.r-project.org/web/packages/ptable/vignettes/introduction.html">vignette</a> for examples.</p>
<p><img src="ptable.png" height = "400" width="600" alt="Plot of Distribution of the Perturbation Values vs Noise"></p>
<p><a href="https://cran.r-project.org/package=snha">snha</a> v0.1.3: Implements the <a href="https://www.mdpi.com/1660-4601/18/4/1741">St. Nicolas House Analysis</a> to explore interacting variables and create correlation networks. See the <a href="https://cran.r-project.org/web/packages/snha/vignettes/tutorial.html">vignette</a>.</p>
<p><img src="snha.png" height = "400" width="600" alt="Plots contrasting PCA and SNHA approaches to variable interactions"></p>
<p><a href="https://cran.r-project.org/package=satdad">satdad</a> v1.1: Implements theoretical and non-parametric tools to analyze tail dependence in sample based or theoretical models. A goal is to generate multivariate extreme value models in any dimension. See the extensive <a href="Networks of extremal coefficients">vignette</a>.</p>
<p><img src="satdad.png" height = "400" width="600" alt="Plots "></p>
<p><a href="https://cran.r-project.org/package=sr">sr</a> v0.1.0: Implements the Gamma test based smooth regression method for measuring smoothness in multivariate relationships, finding causal connections in precision data, finding lags and embeddings in time series, and training neural networks. See <a href="https://royalsocietypublishing.org/doi/10.1098/rspa.2002.1010">Evans & Jones (2002)</a> and Jones <a href="https://link.springer.com/article/10.1007/s10287-003-0006-1">(2004)</a> for details and the <a href="https://cran.r-project.org/web/packages/sr/vignettes/time_series.html">vignette</a> for examples.</p>
<p><img src="sr.png" height = "400" width="600" alt="Plot of Henon Model using Gamma"></p>
<p><a href="https://cran.r-project.org/package=wqspt">wqspt</a> v1.0.1: Implements a permutation test method for the weighted quantile sum (WQS) regression used to evaluate the effect of complex exposure mixtures on an outcome. See <a href="https://link.springer.com/article/10.1007/s13253-014-0180-3">Carrico et al. (2015)</a> and <a href="https://ehp.niehs.nih.gov/doi/10.1289/EHP10570">Day et al. (2022)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/wqspt/vignettes/introduction.html">vignette</a> for examples.</p>
<p><img src="wqspt.png" height = "300" width="200" alt="Table of weights from permutation test"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=coconots">coconots</a> v1.1.1: Provides tools for fitting, validating, and forecasting practical convolution-closed time series models for low counts. The models are described in <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1467-9892.2010.00697.x">Jung and Tremayne (2011)</a>, and the model assessment tools are presented in <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1541-0420.2009.01191.x">Czado et al. (2009)</a>, <a href="https://www.tandfonline.com/doi/abs/10.1198/016214506000001437">Gneiting and Raftery (2007)</a>, and, <a href="https://www.jstor.org/stable/2347612?origin=crossref">Tsay (1992)</a>. See <a href="https://cran.r-project.org/web/packages/coconots/readme/README.html">README</a> for examples.</p>
<p><img src="coconots.png" height = "400" width="600" alt="Diagram showing functionality"></p>
<p><a href="https://cran.r-project.org/package=sparseDFM">sparseDFM</a> v1.0: Implements various estimation methods for dynamic factor models (DFMs) including PCA, see <a href="https://www.tandfonline.com/doi/abs/10.1198/016214502388618960">Stock and Watson (2002)</a>, and EM, see <a href="https://onlinelibrary.wiley.com/doi/10.1002/jae.2306">Banbura and Modugno (2014)</a> and <a href="https://arxiv.org/abs/2303.11892">DFMs Mosley et al. (2023)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/sparseDFM/vignettes/exports-example.html">Nowcasting UK Trade in Goods</a> and <a href="https://cran.r-project.org/web/packages/sparseDFM/vignettes/inflation-example.html">Inflation</a>.</p>
<p><img src="sparseDM.png" height = "400" width="600" alt="Plot of factor loadings"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=askgpt">askgpt</a> v0.0.2: Implements a connection to the <a href="https://platform.openai.com/">OpenAI</a> API to answer questions about <code>R</code>. See the <a href="https://cran.r-project.org/web/packages/askgpt/vignettes/Usage.html">vignette</a>.</p>
<p><img src="chat.png" height = "400" width="600" alt="Example of chatGPT answer"></p>
<p><a href="https://cran.r-project.org/package=cellKey">cellKey</a> v1.0.1: Implements a method to protect statistical data by computing cell keys for individual cells in statistical tables. The theory behind the method is described in <a href="https://unece.org/fileadmin/DAM/stats/documents/ece/ces/ge.46/2013/Topic_1_ABS.pdf">Thompson, Broadfoot and Elazar (2013)</a> and
<a href="https://unece.org/fileadmin/DAM/stats/documents/ece/ces/ge.46/2019/mtg1/SDC2019_S2_Germany_Giessing_Tent_AD.pdf">Giessing and Tent (2019)</a>.</p>
<p><a href="https://cran.r-project.org/package=occupationMeasurement">occupationMeasurement</a> v0.2.0: Implements an interface for performing interactive occupation coding during interviews as described in <a href="https://academic.oup.com/jrsssa/article/181/2/379/7069989?login=false">Peycheva et al. (2021)</a> and <a href="https://sciendo.com/article/10.2478/jos-2021-0042">Schierholz et al. (2018)</a>. There are several vignettes including a <a href="https://cran.r-project.org/web/packages/occupationMeasurement/vignettes/occupationMeasurement.html">Getting Started</a> guide, <a href="https://cran.r-project.org/web/packages/occupationMeasurement/vignettes/api.html">Using the API</a>, and <a href="https://cran.r-project.org/web/packages/occupationMeasurement/vignettes/app-questionnaire.html">Custom Questionnaires</a>.</p>
<p><a href="https://cran.r-project.org/package=pracpac">pracpac</a> v0.1.0: Provides functions to streamline the creation of <code>Docker</code> images with <code>R</code> packages and dependencies embedded. See <a href="https://arxiv.org/abs/2303.07876">Nagraj and Turner (2023)</a> for details and the vignettes <a href="https://cran.r-project.org/web/packages/pracpac/vignettes/basic-usage.html">Basic usage</a> and <a href="https://cran.r-project.org/web/packages/pracpac/vignettes/use-cases.html">Use cases</a>.</p>
<p><a href="https://cran.r-project.org/package=RmdConcord">RmdConcord</a> v0.1.6: Supports concordances in <code>R Markdown</code> documents to easily find the source in the <code>.Rmd</code> file of errors detected by <code>HTML tidy</code>. See <a href="https://cran.r-project.org/web/packages/RmdConcord/readme/README.html">README</a> for details and note that the <a href="https://cran.r-project.org/web/packages/RmdConcord/vignettes/Sample.html">vignette</a> serves as a practice file.</p>
<p><a href="https://cran.r-project.org/package=symbol.equation.gpt">symbol.equation.gpt</a> v1.1.1: Provides an interface for adding symbols, smileys, arrows, and building mathematical equations using <code>LaTeX</code> or <code>r2symbols</code> for <code>Markdown</code> and <code>Shiny</code> development. See the <a href="https://cran.r-project.org/web/packages/symbol.equation.gpt/vignettes/using_equations_symbols_r.html">vignette</a>.</p>
<p><img src="symbol.png" height = "400" width="600" alt="Shiny interface"></p>
<p><a href="https://cran.r-project.org/package=tinysnapshot">tinysnapshot</a> v0.0.3: Provides snapshots for unit tests using the <code>tinytest</code> framework and includes expectations to test base <code>R</code> and <code>ggplot2</code> plots as well as console output from <code>print()</code>. See <a href="https://cran.r-project.org/web/packages/tinysnapshot/readme/README.html">README</a> for usage.</p>
<p><img src="tiny.png" height = "400" width="600" alt="Test snapshots"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=PlotBivInvGaus">PlotBivInvGaus</a> v0.1.0: Provides functions to create bivariate inverse Gaussian distribution contour plots for non-negative random variables. See the <a href="https://cran.r-project.org/web/packages/PlotBivInvGaus/vignettes/PlotBivInvGaus.html">vignette</a>.</p>
<p><img src="Biv.png" height = "400" width="600" alt="Density contour plot"></p>
<p><a href="https://cran.r-project.org/package=textBoxPlacement">textBoxplacement</a> v1.0: Provides functions to compute a non-overlapping layout of text boxes to label multiple overlaying curves. See the <a href="https://cran.r-project.org/web/packages/textBoxPlacement/vignettes/textBoxPlacement.html">vignette</a>.</p>
<p><img src="tB.jpeg" height = "400" width="600" alt="Multiple curves with text boxes"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/04/28/march-2023-top-40-new-cran-packages/';</script>
Multistate Models for Medical Applications
https://rviews.rstudio.com/2023/04/19/multistate-models-for-medical-applications/
Wed, 19 Apr 2023 00:00:00 +0000https://rviews.rstudio.com/2023/04/19/multistate-models-for-medical-applications/
<p>Clinical research studies and healthcare economics studies are frequently concerned with assessing the prognosis for survival in circumstances where patients suffer from a disease that progresses from state to state. Standard survival models only directly model two states: alive and dead. Multi-state models enable directly modeling disease progression where patients are observed to be in various states of health or disease at random intervals, but for which, except for death, the times of entering or leaving states are unknown. Multi-state models easily accommodate <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3684949/#:~:text=In%20statistical%20literature%2C%20interval%20censoring,instead%20of%20being%20observed%20exactly.">interval censored</a> intermediate states while making the usual assumption that death times are known but may be <a href="https://en.wikipedia.org/wiki/Censoring_(statistics)">right censored</a>.</p>
<p>A natural way to conceptualize modeling the dynamics of disease progression with interval censored states is as continuous time Markov chains. The following diagram illustrates a possible disease progression model where there is some possibility of dying from any state, but otherwise a patient would progress from being healthy, to mild disease, to severe disease and then perhaps death.</p>
<pre><code>## Loading required package: shape</code></pre>
<p><img src="/2023/04/19/multistate-models-for-medical-applications/index_files/figure-html/unnamed-chunk-1-1.png" width="672" />
It is true that in that the Markov assumption implies that the time patients spend in the various states are exponentially distributed. However, the mathematical theory of stochastic multi-state processes is very rich and can accommodate more realistic models with state dependent hazard rates that vary over time and other relaxations of the Markov assumption. Moreover, there is robust software in R (and other languages) that make multi-state stochastic survival models practical.</p>
<p>In the remainder of this post, I present a variation of a disease progression model discussed by Ardo van den Hout in some detail in his incredibly informative and very readable monograph <a href="https://www.routledge.com/Mult-i--State-Survival-Models-for-Interval-Censored-Data/Hout/p/book/9780367570569">Multi-State Survival Models for Interval Censored Data</a> . Also note that van den Hout’s model is itself an elaboration of the main example presented by Christopher Jackson in the <a href="https://cran.r-project.org/web/packages/msm/vignettes/msm-manual.pdf">vignette</a> to his <code>msm</code>package. This post presents a slower development of the model developed by Jackson and van den Hout that might be easier for a person not already familiar with the <code>msm</code> package to follow.</p>
<pre class="r"><code>library(tidyverse)
library(tidymodels)
library(msm)</code></pre>
<div id="the-data" class="section level3">
<h3>The Data</h3>
<p>The data set explored by both Jackson and van den Hout is the Cardiac Allograft Vasculopathy (CAV) data set which contains the individual histories of angiographic examinations of 622 heart transplant recipients collected at the Papworth Hospital in the United Kingdom. This data is included in the <code>msm</code> package and is a good candidate to be the <em>iris</em> dataset for progressive disease models. It is a rich data set with 2846 rows and multiple covariates, including patient age and time time since transplant, both of which can be use for time scales, multiple state transitions among four states and no missing values. Observations of intermediate states are interval censored and have been recorded varying time intervals. Deaths are “exact” or right censored.</p>
<p>The following code creates a new variable that preserves the original state data for each observation and displays the data in tibble format.</p>
<pre class="r"><code>set.seed(1234)
df <- tibble(cav) %>% mutate(o_state = state)
df</code></pre>
<pre><code>## # A tibble: 2,846 × 11
## PTNUM age years dage sex pdiag cumrej state firstobs statemax o_state
## <int> <dbl> <dbl> <int> <int> <fct> <int> <int> <int> <dbl> <int>
## 1 100002 52.5 0 21 0 IHD 0 1 1 1 1
## 2 100002 53.5 1.00 21 0 IHD 2 1 0 1 1
## 3 100002 54.5 2.00 21 0 IHD 2 2 0 2 2
## 4 100002 55.6 3.09 21 0 IHD 2 2 0 2 2
## 5 100002 56.5 4 21 0 IHD 3 2 0 2 2
## 6 100002 57.5 5.00 21 0 IHD 3 3 0 3 3
## 7 100002 58.4 5.85 21 0 IHD 3 4 0 4 4
## 8 100003 29.5 0 17 0 IHD 0 1 1 1 1
## 9 100003 30.7 1.19 17 0 IHD 1 1 0 1 1
## 10 100003 31.5 2.01 17 0 IHD 1 3 0 3 3
## # ℹ 2,836 more rows</code></pre>
<p>The state table which presents the number of times each pair of states were observed in successive observation times shows that 46 transitions from state 2 (Mild CAV) to state 1 (No CAV), 4 transitions from state 3 (Severe CAV) to Healthy and 13 transitions from Severe CAV to Mild CAV.</p>
<pre class="r"><code>statetable.msm(state = state, subject = PTNUM, data = df)</code></pre>
<pre><code>## to
## from 1 2 3 4
## 1 1367 204 44 148
## 2 46 134 54 48
## 3 4 13 107 55</code></pre>
<p>I will follow van den Hout and assume these backward transitions are misclassified and alter the state variable so there is no back sliding. The following code does this in a tidy way and also creates a new variable b_age which records the baseline age at which patients entered the study. (Note: you can find van den Hout’s code <a href="https://www.ucl.ac.uk/~ucakadl/Book/Ch1_CAV_MsmAnalysis.r">here</a>)</p>
<pre class="r"><code>df1 <- df %>% group_by(PTNUM) %>%
mutate(b_age = min(age),
state = cummax(state)
)</code></pre>
<p>This transformation will make the state transition table conform to the diagram above, but with state 1 representing No CAV rather than Health.</p>
<pre class="r"><code>statetable.msm(state = state, subject = PTNUM, data = df1)</code></pre>
<pre><code>## to
## from 1 2 3 4
## 1 1336 185 40 139
## 2 0 220 52 49
## 3 0 0 140 63</code></pre>
</div>
<div id="setting-up-and-running-the-model" class="section level3">
<h3>Setting Up and Running the Model</h3>
<p>The next step is to set up the model using the function <code>msm()</code> whose great flexibility means that some care must be taken to set parameter values.</p>
<p>First, we set up the initial guess for the intensity matrix, Q, which determines the transition rates among states for a continuous time Markov chain. For the <code>msm</code> function, positive values indicate possible transitions.</p>
<pre class="r"><code># Intensity matrix Q:
q <- 0.01
Q <- rbind(c(0,q,0,q), c(0,0,q,q),c(0,0,0,q),c(0,0,0,0))
qnames <- c("q12","q14","q23","q24","q34")</code></pre>
<p>Next, we set up the covariate structure which van den Hout discusses in his monograph, but does not show in the code on the book’s website referenced above. For this model, transitions from state 1 to state 2 and from state 1 to state 4 depend on time,<code>years</code>, the age of the patient at transplant time <code>b_age</code>, and <code>dage</code>, the age of the donor. The other transitions depend only on <code>dage</code>. So, we see that <code>msm()</code> can deal with time varying covariates as well as permitting individual state transitions to be driven by different covariates.</p>
<pre class="r"><code>covariates = list("1-2" = ~ years + b_age + dage ,
"1-4" = ~ years + b_age + dage ,
"2-3" = ~ dage,
"2-4" = ~ dage,
"3-4" = ~ dage)</code></pre>
<p>Now, we set the remaining parameters for the model.</p>
<pre class="r"><code>obstype <- 1
center <- FALSE
deathexact <- TRUE
method <- "BFGS"
control <- list(trace = 0, REPORT = 1)</code></pre>
<p><strong>obstype = 1</strong> indicates that observations have been taken at arbitrary time points. They are <em>snapshots</em> of the process that are common for panel data.</p>
<p><strong>center = FALSE</strong> means that covariates will not be centered at their means during the maximum likelihood estimation process. The default for this parameter is TRUE.</p>
<p><strong>deathexact = TRUE</strong> indicates that the final absorbing state is exactly observed. This is the defining assumption survival data. In <code>msm</code> this is equivalent to setting obstupe = 3 for state 4, our absorbing state.</p>
<p>** method = BFGS** signals <code>optim()</code> to use the optimization method published simultaneously in 1970 by Broyden, Fletcher, Goldfarb and Shanno. (look <a href="https://en.wikipedia.org/wiki/Charles_George_Broyden">here</a>). This is a quasi-Newton method that uses function values and gradients to build up a picture of the surface to be optimized.</p>
<p><strong>control = list(trace=0,REPORT=1)</strong> indicates more parameters that will be passed to <code>optim()</code>.</p>
<p><strong>REPORT</strong> sets the the frequency of reports for the “BFGS”, “L-BFGS-B” and “SANN” methods if control$trace is positive. Defaults to every 10 iterations for “BFGS” and “L-BFGS-B”, or every 100 temperatures for “SANN”. (Note: SANN is a variant of the simulated annealing method presented by C. J. P. Belisle (1992) <em>Convergence theorems for a class of simulated annealing algorithms on R<sup>d</sup></em> Journal of Applied Probability.)</p>
<p><strong>trace</strong> is also passed to<code>optim()</code>. trace must be a non-negative integer. If positive, tracing information on the progress of the optimization is produced. Higher values may produce more tracing information.</p>
<pre class="r"><code>model_1 <- msm(state~years, subject = PTNUM, data = df1, center= center,
qmatrix=Q, obstype = obstype, deathexact = deathexact, method = method,
covariates = covariates, control = control)</code></pre>
<p>First check to see if the model has converged. For the BFGS method, possible convergence codes returned by <code>optim()</code> are:
0 indicates convergence, 1 indicates that the maximum iteration limit has been reached, 51 and 52 indicate warnings.</p>
<pre class="r"><code>#Model Status
conv <- model_1$opt$convergence; cat("Convergence code =", conv,"\n")</code></pre>
<pre><code>## Convergence code = 0</code></pre>
<p>Next, look at a measure of how well the model fits the data proposed by using a visual test proposed by <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.4780130803">Gentleman et al. (1994)</a> which plots the observed numbers of individuals occupying a state at a series of times against forecasts from the fitted model, for each state. The <code>msm</code> function <code>plot.prevalence.msm()</code> produces a perfectly adequate base R plot. However, to emphasize that <code>msm</code> users are not limited to base R plots, I’ll do a little extra work to use <code>ggplot()</code>. When a package author is kind enough to provide an extractor function you can do anything you want with the data.</p>
<p>The <code>prevalence.msm()</code> function extracts both the observed and forecast prevalence matrices.</p>
<pre class="r"><code>prev <- prevalence.msm(model_1)</code></pre>
<p>This not very elegant, but straightforward code reshapes the data and plots.</p>
<pre class="r"><code># reshape observed prevalence
do1 <-as_tibble(row.names(prev$Observed)) %>% rename(time = value) %>%
mutate(time = as.numeric(time))
do2 <-as_tibble(prev$Observed) %>% mutate(type = "observed")
do <- cbind(do1,do2) %>% select(-Total)
do_l <- do %>% gather(state, number, -time, -type)
# reshape expected prevalence
de1 <-as_tibble(row.names(prev$Expected)) %>% rename(time = value) %>%
mutate(time = as.numeric(time))
de2 <-as_tibble(prev$Expected) %>% mutate(type = "expected")
de <- cbind(de1,de2) %>% select(-Total)
de_l <- de %>% gather(state, number, -time, -type)
# bind into a single data frame
prev_l <-rbind(do_l,de_l) %>% mutate(type = factor(type),
state = factor(state),
time = round(time,3))
# plot for comparison
prev_gp <- prev_l %>% group_by(state)
pp <- prev_l %>% ggplot() +
geom_line(aes(time, number, color = type)) +
xlab("time") +
ylab("") +
ggtitle("")
pp + facet_wrap(~state)</code></pre>
<p><img src="/2023/04/19/multistate-models-for-medical-applications/index_files/figure-html/unnamed-chunk-13-1.png" width="672" /></p>
<p>The agreement of the observed and forecast prevalence for states 1 through 3 look pretty good. After about 8 years the observed deaths are notably higher than the forecast. As Jackson points out (See the <a href="https://cran.r-project.org/web/packages/msm/vignettes/msm-manual.pdf">msm Manual</a> page 33), this kind of discrepancy could indicate that the underlying process is not homogeneous. I have attempted to capture this non-homogeneity by having some of the transitions depend on time. And, although the plot above looks a little better that than the plot in the manual, which does not attempt to model non-homogeneity, it is apparent that there is room to find a better model!</p>
</div>
<div id="survival-curves-and-calculations" class="section level3">
<h3>Survival Curves and Calculations</h3>
<p>Now, we can jump straight to the major result and look at the fitted survival curves. There is a <code>plot()</code> method for <code>msm</code> that will directly plot these curves. However, just to emphasize that if a package author is kind enough to provide a <code>plot</code> method, it will probably not be too difficult to hack the code for the method to use an alternative plotting system. To save space, I will not show my code, but you can easily recreate it by stating with the <code>plot.msm()</code> function, deleting the plotting parts and returning the values for time and the states “Health, Mild_CAV, and Severe_CAV which are used int the code below. Check my hack by running <code>plot(model_1)</code></p>
<pre class="r"><code># plot_prep was obtained from plot.msm()
res <- plot_prep(model_1)
time <- res[[1]]
Health <- res[[2]]
Mild_CAV <- res[[3]]
Severe_CAV <- res[[4]]
df_w <- tibble(time,Health, Mild_CAV, Severe_CAV)
df_l <- df_w %>% gather("state", "survival", -time)
p <- df_l %>% ggplot(aes(time, 1 - survival, group = state)) +
geom_line(aes(color = state)) +
xlab("Years") +
ylab("Probability") +
ggtitle("Fitted Survival Probabilities")
p</code></pre>
<p><img src="/2023/04/19/multistate-models-for-medical-applications/index_files/figure-html/unnamed-chunk-15-1.png" width="672" /></p>
<p>These curves indicate that a treatment that could prevent CAV or at least delay progression from mild CAV to severe CAV might prolong survival. Additionally, the Markov structure of the model permits extracting information that relates to disease progression and the total time spent in each state.</p>
<p>The function <code>totlos.msm()</code> estimates the total expected time that a patient will spend in each state. Parameter settings for this function include:</p>
<p><strong>start</strong> = c(1,0,0,0) specifies that patients will start in state 1 with probability 0.</p>
<p><strong>fromt</strong> = 0 indicates starting at the beginning of the process.</p>
<p><strong>covariates</strong> = “mean” indicates that the covariates will be set to their mean values for the calculation.</p>
<pre class="r"><code>total_state_time <-totlos.msm(model_1,start = c(1,0,0,0), from = 0, covariates = "mean")
total_state_time</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## 7.002 2.473 1.621 Inf</code></pre>
<p>The table indicates that the mean time a patient can expect to avoid CAV is about 7 years. After progressing to a Mild_CAV, a patient can expect five additional years.</p>
<p>A more direct calculation based on the intensity matrix, Q, give the expected time to the “absorbing” state, Death, from each of the “transient” living states.</p>
<pre class="r"><code>time_to_death <- efpt.msm(model_1, tostate = 4, covariates = "mean")
time_to_death</code></pre>
<pre><code>## [1] 11.097 5.836 3.005 0.000</code></pre>
<p>This agrees with the total state times calculated above.</p>
<pre class="r"><code>sum(total_state_time[1:3])</code></pre>
<pre><code>## [1] 11.1</code></pre>
<p>Within the scope of the information provided by the covariates, it is also possible to generate more individualized forecasts. For example, here is the expected time to death for a person starting off with no CAV at age 60, who received a heart from a 20 year old donor, 5 years after the transplant.</p>
<pre class="r"><code>efpt.msm(model_1, tostate = 4, start = c(1,0,0,0), covariates = list(years = 5, b_age = 60, dage = 20))</code></pre>
<pre><code>## [,1]
## [1,] 7.953</code></pre>
<p>A related quantity, mean sojourn time, is the mean time that each visit to each state is expected to last. Since, we are assuming a progressive disease model where each patient visits each state only once, the estimate should be close to total time spent in each state. However, Jackson notes that in a progressive model, sojourn time in the disease state will be greater than the expected length of stay in the disease state because the mean sojourn time in a state is conditional on entering the state, whereas the expected total time in a diseased state is a forecast for an individual, who may die before getting the disease. (See help(totlos.msm)). And indeed, that is what we see here for states 2 and 3.</p>
<pre class="r"><code>sojourn.msm(model_1, covariates="mean")</code></pre>
<pre><code>## estimates SE L U
## State 1 7.002 0.4024 6.256 7.837
## State 2 3.525 0.3020 2.980 4.169
## State 3 3.005 0.3748 2.353 3.837</code></pre>
</div>
<div id="hazard-ratios" class="section level3">
<h3>Hazard Ratios</h3>
<p><code>model_1</code> will also product estimates of hazard ratios which show the estimate effect on transition intensities for each state.</p>
<p>Here is the table of Hazard Ratios:</p>
<pre class="r"><code>model_1</code></pre>
<pre><code>##
## Call:
## msm(formula = state ~ years, subject = PTNUM, data = df1, qmatrix = Q, obstype = obstype, covariates = covariates, deathexact = deathexact, center = center, method = method, control = control)
##
## Maximum likelihood estimates
## Baselines are with covariates set to 0
##
## Transition intensities with hazard ratios for each covariate
## Baseline years
## State 1 - State 1 -0.032750 (-0.0607897,-0.017644)
## State 1 - State 2 0.030957 ( 0.0160470, 0.059721) 1.112 (1.061,1.166)
## State 1 - State 4 0.001793 ( 0.0004703, 0.006836) 1.093 (1.012,1.182)
## State 2 - State 2 -0.395633 (-0.6488723,-0.241227)
## State 2 - State 3 0.264310 ( 0.1488153, 0.469441) 1.000
## State 2 - State 4 0.131323 ( 0.0330133, 0.522385) 1.000
## State 3 - State 3 -0.434548 (-0.9113857,-0.207192)
## State 3 - State 4 0.434548 ( 0.2071918, 0.911386) 1.000
## b_age dage
## State 1 - State 1
## State 1 - State 2 1.001 (0.9884,1.014) 1.0281 (1.0159,1.040)
## State 1 - State 4 1.053 (1.0271,1.079) 1.0208 (1.0039,1.038)
## State 2 - State 2
## State 2 - State 3 1.000 0.9932 (0.9756,1.011)
## State 2 - State 4 1.000 0.9757 (0.9298,1.024)
## State 3 - State 3
## State 3 - State 4 1.000 0.9906 (0.9672,1.015)
##
## -2 * log-likelihood: 3466</code></pre>
<p>The table shows that time, the covariate <code>years</code>, affects disease progression represented by the the transition from state 1 to state 2, but has a smaller effect on the transition from state 1 to state 4.</p>
<p>The covariate <code>b_age</code>, the baseline age of patient at transplant time has a larger effect on dying before the onset of CAV than on the transition to CAV.</p>
<p>The covariate <code>dage</code> has a minor effect on the transitions from state 1 but apparently has no effect thereafter.</p>
<p>The hazard ratios are computed by calculating the exponential of the estimated covariate effects on the log-transition intensities for the Markov process which are stored in the model object.</p>
<p>To see how these work, first look at the baseline hazard ratios.</p>
<pre class="r"><code>model_1$Qmatrices$baseline</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 -0.03275 0.03096 0.0000 0.001793
## State 2 0.00000 -0.39563 0.2643 0.131323
## State 3 0.00000 0.00000 -0.4345 0.434548
## State 4 0.00000 0.00000 0.0000 0.000000</code></pre>
<p>These baseline hazard ratios are computed from the model intensity matrix, Q, assuming no covariates. They can also be directly extracted from the model by <code>qmatrix.msm()</code> extractor function with covariates set to zero.</p>
<pre class="r"><code>qmatrix.msm(model_1, covariates = 0)</code></pre>
<pre><code>## State 1 State 2
## State 1 -0.032750 (-0.0607897,-0.017644) 0.030957 ( 0.0160470, 0.059721)
## State 2 0 -0.395633 (-0.6488723,-0.241227)
## State 3 0 0
## State 4 0 0
## State 3 State 4
## State 1 0 0.001793 ( 0.0004703, 0.006836)
## State 2 0.264310 ( 0.1488153, 0.469441) 0.131323 ( 0.0330133, 0.522385)
## State 3 -0.434548 (-0.9113857,-0.207192) 0.434548 ( 0.2071918, 0.911386)
## State 4 0 0</code></pre>
<p>The 95% confidence limits are computed by assuming normality of the log-effect.</p>
<p>A more representative value for the intensity matrix for this model can be obtained by setting the covariates to their expected mean values.</p>
<pre class="r"><code>qmatrix.msm(model_1, covariates = "mean")</code></pre>
<pre><code>## State 1 State 2
## State 1 -0.14281 (-0.15984,-0.12760) 0.10019 ( 0.08742, 0.11482)
## State 2 0 -0.28369 (-0.33556,-0.23984)
## State 3 0 0
## State 4 0 0
## State 3 State 4
## State 1 0 0.04262 ( 0.03339, 0.05441)
## State 2 0.21821 ( 0.17636, 0.26999) 0.06548 ( 0.03872, 0.11075)
## State 3 -0.33281 (-0.42498,-0.26064) 0.33281 ( 0.26064, 0.42498)
## State 4 0 0</code></pre>
<p>Next, we may want to examine the contribution of the covariate covariates to the hazard ratios. To take a particular example, look at the <code>dage</code> to the hazard ratios</p>
<pre class="r"><code>model_1$Qmatrices$dage</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0 0.02771 0.000000 0.020575
## State 2 0 0.00000 -0.006783 -0.024625
## State 3 0 0.00000 0.000000 -0.009439
## State 4 0 0.00000 0.000000 0.000000</code></pre>
<p>and focus on the contribution of <code>dage</code> to the intensity matrix for the transition from state 3 to state 4 which is given as -0.009439 in the table above. Taking the exponential of this value, yields the hazard ratio for the <code>dage</code> state 3 to 4 transition in the hazard ratio’s table we got by printing out <code>model_1</code> above.</p>
<pre class="r"><code>exp(-.009439)</code></pre>
<pre><code>## [1] 0.9906</code></pre>
<p>The hazard ratio tables for the remaining covariates are given by:</p>
<pre class="r"><code>model_1$Qmatrices$years</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0 0.1064 0 0.08933
## State 2 0 0.0000 0 0.00000
## State 3 0 0.0000 0 0.00000
## State 4 0 0.0000 0 0.00000</code></pre>
<p>and</p>
<pre class="r"><code>model_1$Qmatrices$b_age</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0 0.0009645 0 0.05152
## State 2 0 0.0000000 0 0.00000
## State 3 0 0.0000000 0 0.00000
## State 4 0 0.0000000 0 0.00000</code></pre>
</div>
<div id="exploring-transition-probabilities-and-intensities" class="section level3">
<h3>Exploring Transition Probabilities and Intensities</h3>
<p>It is also possible to look at the state transition matrix at different times and see how these probabilities change over time. Here we compute the transition matrix at 1 year.</p>
<pre class="r"><code>pmatrix.msm(model_1, t = 1, covariates = "mean")</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0.8669 0.08101 0.008493 0.04357
## State 2 0.0000 0.75300 0.160340 0.08666
## State 3 0.0000 0.00000 0.716903 0.28310
## State 4 0.0000 0.00000 0.000000 1.00000</code></pre>
<p>and at 5 years.</p>
<pre class="r"><code>pmatrix.msm(model_1, t = 5, covariates = "mean")</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0.4897 0.1761 0.07871 0.2556
## State 2 0.0000 0.2421 0.23419 0.5237
## State 3 0.0000 0.0000 0.18937 0.8106
## State 4 0.0000 0.0000 0.00000 1.0000</code></pre>
<p>Additionally, it is possible to examine the effect of covariates on transition probabilities. Here are the 5 year transition probabilities for a patient with a baseline age of 35.</p>
<pre class="r"><code>pmatrix.msm(model_1, t = 5, covariates = list(years = 5, b_age = 35, dage = 20))</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0.5474 0.1674 0.07575 0.2095
## State 2 0.0000 0.2112 0.21622 0.5726
## State 3 0.0000 0.0000 0.16547 0.8345
## State 4 0.0000 0.0000 0.00000 1.0000</code></pre>
<p>and those who had the procedure at age 60.</p>
<pre class="r"><code>pmatrix.msm(model_1, t = 5, covariates = list(years = 5, b_age = 60, dage = 20))</code></pre>
<pre><code>## State 1 State 2 State 3 State 4
## State 1 0.3863 0.1409 0.06784 0.4050
## State 2 0.0000 0.2112 0.21622 0.5726
## State 3 0.0000 0.0000 0.16547 0.8345
## State 4 0.0000 0.0000 0.00000 1.0000</code></pre>
<p>Note that the transitions from CAV states are unaffected.</p>
<p>To summarize: Continuous Time Markov Chains provide a natural framework for working with multi-state survival models. The <code>msm</code> package is sufficiently sophisticated to permit modeling clinical process with level of fidelity that may provide insight about clinically observed disease progression. The software is relatively easy to use and there is plenty of documentation to help you get started.</p>
</div>
<div id="learning-more-about-multi-state-survival-models" class="section level3">
<h3>Learning More About Multi-State Survival Models</h3>
<p>To dive deeper into multi-state survival models, I am sure you will find Ardo van den Hout’ <a href="https://www.routledge.com/Multi-State-Survival-Models-for-Interval-Censored-Data/Hout/p/book/9780367570569">Multi-State Survival Models for Interval-Censored Data</a> extraordinarily helpful. There are many good textbooks about the basics of Continuous Time Markov Chains. I recommend J.R.Norris’ - <a href="https://www.cambridge.org/core/books/markov-chains/A3F966B10633A32C8F06F37158031739">Markov Chains</a> which is still modestly priced. There are also many expositions freely available on the internet including:</p>
<ul>
<li><p>David F. Anderson - <a href="https://u.math.biu.ac.il/~amirgi/CTMCnotes.pdf">Chapter 6: Continuous Time Markov Chains</a> from <a href="https://u.math.biu.ac.il/~amirgi/SBA.pdf">Lecture Notes on Stochastic Processes with Applications in Biology</a></p></li>
<li><p>Miranda Holmes-Cerfon - <a href="https://cims.nyu.edu/~holmes/teaching/asa19/handout_Lecture4_2019.pdf">Lecture 4: Continuous-time Markov Chains</a></p></li>
<li><p>Søren Feodor Nielsen - <a href="http://web.math.ku.dk/~susanne/kursusstokproc/ContinuousTime.pdf">Continuous-time homogeneous Markov chains</a></p></li>
<li><p>Karl Sigman - <a href="http://www.columbia.edu/~ks20/stochastic-I/stochastic-I-CTMC.pdf">Continuous-Time Markov Chains</a></p></li>
</ul>
</div>
<script>window.location.href='https://rviews.rstudio.com/2023/04/19/multistate-models-for-medical-applications/';</script>
A data analyst workflow, part 1: SQL & tidyverse
https://rviews.rstudio.com/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/
Thu, 06 Apr 2023 00:00:00 +0000https://rviews.rstudio.com/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/
<p><em>Vidisha Vachharajani works in the EdTech industry, where she enjoys developing data-driven strategy solutions for learners. She has been an R user for over 15 years.</em></p>
<p>As a data professional, I have enjoyed learning and using multiple tools for my workflows. For me, everything used to begin and end with R. Today, SQL is a must-know. Not being able to pull your own custom tables from a warehouse can make things tricky. Then there is <code>tidyverse</code>, the master collection of packages for data science & analytics. As an OG R user, I cannot envision data work without <code>tidyverse</code>.</p>
<p>In this first part of a 2-part article, I want to demonstrate how a data analyst can use <em>one OR the other for the initial stages of data exploration</em>, and then double down on <code>tidyverse</code>, leveraging <code>ggplot2</code> for a deeper exploration. By no means does this preclude the extensive use of SQL for data wrangling. Rather, this post showcases the wonders of <code>tidyverse</code> (a <a href="https://www.tidyverse.org/">collection</a> of R packages designed for data science, sharing an underlying design philosophy, grammar, and data structures) and specifically, <code>ggplot2</code> (the <a href="https://ggplot2-book.org/">language</a> of elegant graphics) for a SQL user’s benefit.</p>
<div id="the-dataset-and-the-goal" class="section level2">
<h2>1. The dataset and the goal</h2>
<p>The dataset I am using is clinical. Sourced from the UCI machine learning repo, it is the <em>Diabetes 130-US hospitals for years 1999-2008 Data Set</em>. The dataset is large, ~100K rows and 51 columns in its raw format. It is, however, clean data. For the purpose of this article, in order to show SQL and <code>tidyverse</code> language in tandem, I will split it up into 5 parts, and we will assume that the data is actually available to us in these 5 different pieces, rather than as the whole, cleaned data, since this is typically the case in real life.</p>
<p>I will skip the portion about <a href="https://dbplyr.tidyverse.org/articles/dbplyr.html"><code>dbplyr</code></a>, referring readers to the hyperlinked article that will show you how to actually pull data from a remote database using <code>tidyverse</code>’s <code>dbplyr</code>. Typically, this is done using SQL, but<code>dbplyr</code> allows you to do this within <code>R</code>. Rather, I will focus on <em>the initial stages of data exploration</em>, using both SQL and <code>tidyverse</code> for the same output, while extending the <code>tidyverse</code> portion to include <code>ggplot2</code> visualization examples, using different plot types for each use case. Note that in each case, you can use SQL first, and then use the SQL output as an input for the <code>ggplot2</code> visualization.</p>
</div>
<div id="reading-in-the-data" class="section level2">
<h2>2. Reading in the data</h2>
<p>The data has been split into 5 parts – demographic, medical, hospital visits, outcome, test results. To learn more about the actual data, see <a href="https://www.hindawi.com/journals/bmri/2014/781670/">here</a>. Each part is connected with the other through a UID that is a concatenation of the patient encounter ID and the patient number (using either one doesn’t work to make the ID unique). Note that all of the analyses in this post will be done at the UID level, rather than patient level.</p>
<pre class="r"><code>#rm(list=ls())
library(sqldf)
library(dplyr)
library(readxl)
#library(dbplyr)
library(ggplot2)
data_path <- "./dataset_diabetes/diabetic_data.xlsx"
dem <- read_excel(data_path, "demo")
meds <- read_excel(data_path, "medications")
visits <- read_excel(data_path, "hosp_visits")
y <- read_excel(data_path, "readmissions")
results <- read_excel(data_path, "test_results")</code></pre>
</div>
<div id="early-explorations" class="section level2">
<h2>3. Early explorations</h2>
<p>Let’s begin using SQL and <code>tidyverse</code> to answer some initial questions related to the dataset. The primary hypothesis for this data is the <strong>impact of HbA1c measurement on readmission rates</strong>, where “readmission” is our response. We will also answer a number of other questions along the way to understand the data better, using <code>ggplot2</code> when we can.</p>
<div id="look-at-the-data" class="section level3">
<h3>3.1 Look at the data</h3>
<div id="get-some-counts" class="section level4">
<h4>3.1.1 Get some counts</h4>
<p>Let’s take a look at medications and get a sample size for it, first using SQL and then <code>R</code>.</p>
<pre class="r"><code>sqldf('SELECT * FROM meds where 1=0') # SQL see col names</code></pre>
<pre><code>## [1] uid metformin repaglinide
## [4] nateglinide chlorpropamide glimepiride
## [7] acetohexamide glipizide glyburide
## [10] tolbutamide pioglitazone rosiglitazone
## [13] acarbose miglitol troglitazone
## [16] tolazamide examide citoglipton
## [19] insulin glyburide-metformin glipizide-metformin
## [22] glimepiride-pioglitazone metformin-rosiglitazone metformin-pioglitazone
## [25] change diabetesMed
## <0 rows> (or 0-length row.names)</code></pre>
<pre class="r"><code>sqldf('SELECT uid, metformin, repaglinide, nateglinide, chlorpropamide FROM meds LIMIT 5') # SQL</code></pre>
<pre><code>## uid metformin repaglinide nateglinide chlorpropamide
## 1 2278392-8222157 No No No No
## 2 149190-55629189 No No No No
## 3 64410-86047875 No No No No
## 4 500364-82442376 No No No No
## 5 16680-42519267 No No No No</code></pre>
<pre class="r"><code>head(meds, n=5) # dplyr</code></pre>
<pre><code>## # A tibble: 5 × 26
## uid metfo…¹ repag…² nateg…³ chlor…⁴ glime…⁵ aceto…⁶ glipi…⁷ glybu…⁸ tolbu…⁹
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 22783… No No No No No No No No No
## 2 14919… No No No No No No No No No
## 3 64410… No No No No No No Steady No No
## 4 50036… No No No No No No No No No
## 5 16680… No No No No No No Steady No No
## # … with 16 more variables: pioglitazone <chr>, rosiglitazone <chr>,
## # acarbose <chr>, miglitol <chr>, troglitazone <chr>, tolazamide <chr>,
## # examide <chr>, citoglipton <chr>, insulin <chr>,
## # `glyburide-metformin` <chr>, `glipizide-metformin` <chr>,
## # `glimepiride-pioglitazone` <chr>, `metformin-rosiglitazone` <chr>,
## # `metformin-pioglitazone` <chr>, change <chr>, diabetesMed <chr>, and
## # abbreviated variable names ¹metformin, ²repaglinide, ³nateglinide, …</code></pre>
<pre class="r"><code>sqldf('SELECT COUNT(uid) FROM meds') # SQL</code></pre>
<pre><code>## COUNT(uid)
## 1 101766</code></pre>
<pre class="r"><code>nrow(meds) # R</code></pre>
<pre><code>## [1] 101766</code></pre>
<p>How many patients with a diabetes diagnosis, vs respiratory, circulatory, etc.?</p>
<pre class="r"><code>sqldf('SELECT primary_diag, COUNT(*) FROM results GROUP BY primary_diag') # SQL</code></pre>
<pre><code>## primary_diag COUNT(*)
## 1 circulatory 30437
## 2 diabetes 8757
## 3 other 48149
## 4 respiratory 14423</code></pre>
<pre class="r"><code>results %>% group_by(primary_diag) %>% count(primary_diag) # R</code></pre>
<pre><code>## # A tibble: 4 × 2
## # Groups: primary_diag [4]
## primary_diag n
## <chr> <int>
## 1 circulatory 30437
## 2 diabetes 8757
## 3 other 48149
## 4 respiratory 14423</code></pre>
<p>How many women came in through an emergency admission type?</p>
<pre class="r"><code>sqldf('SELECT gender, admission_type_id, COUNT(*) AS n FROM dem LEFT JOIN visits USING(uid) WHERE admission_type_id=1 GROUP BY gender') # SQL</code></pre>
<pre><code>## gender admission_type_id n
## 1 Female 1 29448
## 2 Male 1 24540
## 3 Unknown/Invalid 1 2</code></pre>
<pre class="r"><code>visits %>% left_join(dem, by=join_by(uid)) %>% subset(admission_type_id==1) %>% count(gender, admission_type_id) # dplyr</code></pre>
<pre><code>## # A tibble: 3 × 3
## gender admission_type_id n
## <chr> <dbl> <int>
## 1 Female 1 29448
## 2 Male 1 24540
## 3 Unknown/Invalid 1 2</code></pre>
</div>
<div id="a-mosaic-plot" class="section level4">
<h4>3.1.2 A mosaic plot</h4>
<p>Instead of extracting counts manually, let’s use a mosaic plot to get a sense of how 2 count variables are distributed relative to each other. In this case, age and admission type. This plot sheds light into data availability and asymmetric distributions. For example, here, we see that most patients come from emergency, urgent care, or as an elective, and that there is missing or “not available” admission type data. It is important to retain these 2 categories separately, since they mean different things. Note that in the <code>ggplot</code> parameters, I have not yet introduced axes label cleanup, etc.</p>
<pre class="r"><code>p0 <- dem %>% left_join(visits, by=join_by(uid)) %>%
mutate(admission_type=ifelse(admission_type_id==1, "1:Emergency",
ifelse(admission_type_id==2, "2:Urgent",
ifelse(admission_type_id==3, "3:Elective",
ifelse(admission_type_id==4, "4:Newborn",
ifelse(admission_type_id==5, "5:Not Available",
ifelse(admission_type_id==6, "6:NULL",
ifelse(admission_type_id==7, "7:Trauma Center",
"8:Not Mapped")))))))) %>%
group_by(admission_type, age) %>% summarise(n=n()) %>% mutate(freq = n / sum(n))
ggplot(p0, aes(x=age, y=admission_type)) +
geom_tile(aes(fill=n)) + scale_fill_gradient(low="white", high="blue")</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/mosaic-1.png" width="672" /></p>
</div>
<div id="a-simple-join" class="section level4">
<h4>3.1.3 A simple join</h4>
<p>Let’s join all 5 datasets and look at it. Note that in SQL, in order to look only at the first few columns, we need to know the column names, which is what we first do here.</p>
<pre class="r"><code># (Output suppressed)
sqldf('SELECT * FROM dem LEFT JOIN visits USING(uid) LEFT JOIN results USING(uid) LEFT JOIN meds USING(uid) LEFT JOIN y USING(uid) where 1=0') # SQL</code></pre>
<pre class="r"><code>sqldf('SELECT uid, race, gender, age, weight FROM dem LEFT JOIN visits USING(uid) LEFT JOIN results USING(uid) LEFT JOIN meds USING(uid) LEFT JOIN y USING(uid) LIMIT 5') # SQL</code></pre>
<pre><code>## uid race gender age weight
## 1 2278392-8222157 Caucasian Female [0-10) ?
## 2 149190-55629189 Caucasian Female [10-20) ?
## 3 64410-86047875 AfricanAmerican Female [20-30) ?
## 4 500364-82442376 Caucasian Male [30-40) ?
## 5 16680-42519267 Caucasian Male [40-50) ?</code></pre>
<pre class="r"><code>dem %>% left_join(visits, by=join_by(uid)) %>% left_join(results, by=join_by(uid)) %>% left_join(meds, by=join_by(uid)) %>% left_join(y, by=join_by(uid)) %>% print(n=5) # dplyr, by default shows 10 rows, so we ask it to print 5</code></pre>
<pre><code>## # A tibble: 101,766 × 50
## uid race gender age weight admis…¹ disch…² admis…³ time_…⁴ payer…⁵
## <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 2278392-822… Cauc… Female [0-1… ? 6 25 1 1 ?
## 2 149190-5562… Cauc… Female [10-… ? 1 1 7 3 ?
## 3 64410-86047… Afri… Female [20-… ? 1 1 7 2 ?
## 4 500364-8244… Cauc… Male [30-… ? 1 1 7 2 ?
## 5 16680-42519… Cauc… Male [40-… ? 1 1 7 1 ?
## # … with 101,761 more rows, 40 more variables: medical_specialty <chr>,
## # num_lab_procedures <dbl>, num_procedures <dbl>, num_medications <dbl>,
## # number_outpatient <dbl>, number_emergency <dbl>, number_inpatient <dbl>,
## # diag_1 <chr>, diag_2 <chr>, diag_3 <chr>, number_diagnoses <dbl>,
## # max_glu_serum <chr>, A1Cresult <chr>, primary_diag <chr>, metformin <chr>,
## # repaglinide <chr>, nateglinide <chr>, chlorpropamide <chr>,
## # glimepiride <chr>, acetohexamide <chr>, glipizide <chr>, glyburide <chr>, …</code></pre>
</div>
</div>
<div id="explore-the-response-readmissions" class="section level3">
<h3>3.2 Explore the response: readmissions</h3>
<div id="lab-procedures" class="section level4">
<h4>3.2.1 Lab procedures</h4>
<p>Let’s start with the simplest question – for the primary response variable, “readmitted”, how many lab procedures were done by each category of the response? Note here that “number of lab procedures” is one of a handful of continuous design covariate – rest of the ~45 covariates are all categorical/discrete.</p>
<pre class="r"><code># How many lab tests performed for readmitted patients
sqldf('SELECT readmitted, SUM(num_lab_procedures) AS n FROM visits LEFT JOIN y USING(uid) GROUP BY readmitted') # SQL</code></pre>
<pre><code>## readmitted n
## 1 <30 502275
## 2 >30 1558172
## 3 NO 2325224</code></pre>
<pre class="r"><code>visits %>% left_join(y, by=join_by(uid)) %>% group_by(readmitted) %>%
summarise(n=sum(num_lab_procedures)) %>% mutate(freq = n / sum(n)) # dplyr, w/ an added proportion </code></pre>
<pre><code>## # A tibble: 3 × 3
## readmitted n freq
## <chr> <dbl> <dbl>
## 1 <30 502275 0.115
## 2 >30 1558172 0.355
## 3 NO 2325224 0.530</code></pre>
<p>Since the above doesn’t really tell us much, other than actual counts, proportions by response categories, let’s use <code>ggplot2</code> to explore the distribution of “number of lab procedures”, using a barplot/histogram approach, with “readmitted” as the <code>fill</code> element. This helps us get a better picture of their relationship; we see here how, for a strikingly normally distributed “number of lab procedures” (other than 1 outlier), on average, the higher the volume of procedures, the more the proportion of readmitted.</p>
<pre class="r"><code># How many lab tests performed for readmitted patients, use ggplot2
p1 <- visits %>% left_join(y, by=join_by(uid))
ggplot(data = p1 ,aes(x=num_lab_procedures,fill=readmitted)) + geom_bar() + labs(x="Number of lab procedures", y="counts") + scale_y_continuous(
labels = function(n) scales::comma(abs(n)))</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-1-2-1.png" width="672" /></p>
<p>Let’s also do this using <code>ggplot</code>’s beautiful density plots. It is a slightly different type of visual, and tells us how the distribution of X shifts left or right by the response or <code>fill</code>.</p>
<pre class="r"><code>ggplot(p1, aes(num_lab_procedures)) + geom_density(aes(fill=factor(readmitted)), alpha=0.8) + labs(x="Number of lab procedures") </code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-1-3-1.png" width="672" /></p>
</div>
<div id="demographics" class="section level4">
<h4>3.2.2 Demographics</h4>
<p>Next, we ask how readmissions differ across age groups and gender. Let’s also plot this to understand the output better. We first use a population pyramid approach to get the counts and then barplot the proportions to get a better understanding of the variance in readmissions across these groups.</p>
<pre class="r"><code># What are readmission rates by the different age groups?
sqldf('SELECT age, readmitted, COUNT(*) AS n FROM dem LEFT JOIN y USING(uid) GROUP BY age') # SQL</code></pre>
<pre><code>## age readmitted n
## 1 [0-10) NO 161
## 2 [10-20) >30 691
## 3 [20-30) NO 1657
## 4 [30-40) NO 3775
## 5 [40-50) NO 9685
## 6 [50-60) >30 17256
## 7 [60-70) NO 22483
## 8 [70-80) >30 26068
## 9 [80-90) NO 17197
## 10 [90-100) NO 2793</code></pre>
<pre class="r"><code>p21 <- dem %>% left_join(y, by=join_by(uid)) %>% group_by(gender, age, readmitted) %>% summarise(n=n()) %>%
mutate(pct = 100 * n / sum(n), readmission=ifelse(readmitted=="NO", "not readmitted", "readmitted")) %>%
ungroup() %>% subset(gender=="Male"|gender=="Female") %>%
ggplot() +
geom_col(aes(x = ifelse(readmission == "readmitted", -n, n),
y = age,
fill = readmission)) +
facet_wrap(~ gender) +
scale_x_continuous(
labels = function(n) scales::comma(abs(n))) +
xlab("Counts")
p21</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-2-1.png" width="672" /></p>
<pre class="r"><code>p22 <- dem %>% left_join(y, by=join_by(uid)) %>% group_by(gender, age, readmitted) %>% summarise(n=n()) %>% mutate(freq = n / sum(n)) %>% subset(gender=="Male"|gender=="Female")
ggplot(data=p22, aes(x=age, y=freq, fill=readmitted)) + geom_col() + facet_wrap(~ gender) + labs(y="proportions") + geom_text(aes(label = paste0(round(freq, 4) * 100, "%")), position = position_stack(vjust = 0.5), size=2.5, angle=90) + theme(axis.text.x = element_text(angle=90, vjust=.5, hjust=1))</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-2-2.png" width="672" /></p>
<p>The population pyramid is an intriguing plot type, and already tells us that for most age groups, more women are readmitted. But this could be solely because there are more women than men in the sample. However, from the proportion barchart, we see here that proportion of readmitted women is greater than men, particularly for the 20-30 age group.</p>
</div>
<div id="patient-diagnoses" class="section level4">
<h4>3.2.3 Patient diagnoses</h4>
<p>Finally, how are readmission rates distributed by patient and patient care features. For example, how is it distributed by patient primary diagnosis? In the final section of this post, we will leverage <code>ggplot2</code>’s visualization power to triangulate patient diagnoses with the key covariate and the response. Like in the previous section, we use proportions, adding the relevant labels to more easily infer that we see higher readmission rates for a diabetes diagnosis.</p>
<p>We change around quite a few of the plotting parameters in <code>ggplot2</code> to make it look much more eye-catching.</p>
<pre class="r"><code># How is readmitted rate distributed by diagnoses?
sqldf('SELECT primary_diag, readmitted, COUNT(*) as n FROM results LEFT JOIN y USING(uid) GROUP BY primary_diag, readmitted') # SQL</code></pre>
<pre><code>## primary_diag readmitted n
## 1 circulatory <30 3485
## 2 circulatory >30 10839
## 3 circulatory NO 16113
## 4 diabetes <30 1137
## 5 diabetes >30 3318
## 6 diabetes NO 4302
## 7 other <30 5332
## 8 other >30 15856
## 9 other NO 26961
## 10 respiratory <30 1403
## 11 respiratory >30 5532
## 12 respiratory NO 7488</code></pre>
<pre class="r"><code>p3 <- results %>% left_join(y, by=join_by(uid)) %>% group_by(primary_diag, readmitted) %>% summarise(n=n()) %>% mutate(freq = n / sum(n))
ggplot(data=p3, aes(x=primary_diag, y=n, fill=readmitted)) + geom_bar(position = "dodge", stat = "identity", color="black") + scale_fill_manual(values=c("#999999", "#E69F00", "#56B4E9")) + theme_minimal() + labs(x="Primary diagnoses", y="Counts (proportions as labels)") + geom_text(aes(label = paste0(round(freq, 4) * 100, "%")), position = position_dodge(width = 1), vjust=-0.7, size=3) + scale_y_continuous(labels = function(n) scales::comma(abs(n)))</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-3-1.png" width="672" /></p>
</div>
<div id="hba1c-measurement" class="section level4">
<h4>3.2.4 HbA1c measurement</h4>
<p>One of the key questions this dataset seeks to answer is the <em>impact of the A1C test (decision to test) on readmission rates</em>, in the presence of covariates (especially the primary diagnosis). Output in its raw form (i.e. untransformed) doesn’t always give us the answer clearly. To get around this, we will use <code>CASE WHEN</code> in SQL and <code>mutate</code> in <code>tidyverse</code>.</p>
<p>Let’s plot this in 2 ways – a barplot with labels, and a spineplot. The latter allows us to see the “weight” of the underlying categories.</p>
<pre class="r"><code># What is the readmission rate profile of patients who had their A1C measured?
sqldf('SELECT CASE WHEN A1Cresult = "None" THEN "not measured" ELSE "measured" END AS a1c, readmitted,
COUNT(*) FROM results LEFT JOIN y USING(uid) GROUP BY a1c, readmitted ORDER BY 1') # SQL</code></pre>
<pre><code>## a1c readmitted COUNT(*)
## 1 measured <30 1676
## 2 measured >30 5800
## 3 measured NO 9542
## 4 not measured <30 9681
## 5 not measured >30 29745
## 6 not measured NO 45322</code></pre>
<pre class="r"><code>p4 <- results %>% left_join(y, by=join_by(uid)) %>% mutate(a1c=ifelse(A1Cresult=="None", "not measured", "measured")) %>%
group_by(a1c, readmitted) %>% summarise(n=n()) %>% mutate(freq = n / sum(n))
ggplot(data=p4, aes(x=a1c, y=freq, fill=readmitted)) + geom_col() + labs(x="HbA1c test measurement", y="proportions") + geom_text(aes(label = paste0(round(freq, 4) * 100, "%")), position = position_stack(vjust = 0.5), size=3)# dplyr</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-4-1.png" width="672" /></p>
<pre class="r"><code># Spineplot
library(ggmosaic)
p5 <- results %>% left_join(y, by=join_by(uid)) %>% left_join(dem, by=join_by(uid))%>% mutate(a1c=ifelse(A1Cresult=="None", "not measured", "measured")) %>% subset(gender=="Male"|gender=="Female")
per <- p5 %>% group_by(a1c, readmitted) %>% summarise(n=n()) %>% mutate(freq = n / sum(n))
g <- ggplot(p5) + geom_mosaic(aes(x = product(a1c),fill = readmitted))
g + geom_text(data = ggplot_build(g)$data[[1]] %>%
group_by(x__a1c) %>%
mutate(pct = .wt/sum(.wt)*100),
aes(x = (xmin+xmax)/2, y = (ymin+ymax)/2, label=paste0(round(pct, 2), "%")))</code></pre>
<p><img src="/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/index_files/figure-html/explore-4-2.png" width="672" /></p>
<p>We observe a lower readmission rate (<30 days) when there is an A1C measurement taken, vs when it is not measured at all. In the 2nd/spineplot, we see this without actually calculating the percentages, while also inferring that number of patients not measured is much higher than those measured. We do however, manually add in the percentages to the spineplot to get a more complete picture on the relationship between HbA1c measurement and readmission rates.
These are key findings which we will explore in greater detail, using <code>tidyverse</code> and <code>ggplot2</code> more extensively, in the next part of this blog series, including cutting these plots across multiple covariates to explore how HbA1c affects readmissions in the presence of other patient groupings. Stay tuned!</p>
</div>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2023/04/06/a-data-analyst-workflow-part-1-sql-tidyverse/';</script>
February 2023: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/03/28/february-2023-top-40-new-cran-packages/
Tue, 28 Mar 2023 00:00:00 +0000https://rviews.rstudio.com/2023/03/28/february-2023-top-40-new-cran-packages/
<p>One hundred seventy-three new packages made it to CRAN in February. Here are my “Top 40” selections in thirteen categories: Computational Methods, Data, Ecology, Economics, Machine Learning, Mathematics, Medicine, Pharma, Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=dcTensor">dcTensor</a> v1.0.1: Implements semi-binary and semi-ternary matrix methods based on non-negative matrix factorization (NMF) and singular value decomposition (SVD). For the details see the reference section of <a href="https://github.com/rikenbit/dcTensor">GitHub README.md</a>. There are seven vignettes including <a href="https://cran.r-project.org/web/packages/dcTensor/vignettes/dcTensor-2.html">Discretized Singular Value Decomposition</a>, <a href="https://cran.r-project.org/web/packages/dcTensor/vignettes/dcTensor-5.html">Discretized Partial Least Squares</a>, and <a href="https://cran.r-project.org/web/packages/dcTensor/vignettes/dcTensor-7.html">Discretized Non-negative Tucker Decomposition</a>.</p>
<p><img src="dcTensor.png" height = "400" width="600" alt="Plot showing whether the original data is recovered by the dSVD"></p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=dhis2r">dhis2r</a> v0.1.1: Implements a connection to <a href="https://dhis2.org/">DHIS2</a>, a global open-source project coordinated by the HISP Centre at the University of Oslo. See the <a href="https://cran.r-project.org/web/packages/dhis2r/vignettes/dhis2r.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=ispdata">ispdata</a> v1.1: Provides access to data from the Rio de Janeiro Public Security Institute including criminal statistics, data on gun seizures and femicide. See <a href="https://cran.r-project.org/web/packages/ispdata/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=ohsome">ohsome</a> v0.2.1: Implements a client for Heidelberg Institute for Geo information Technology’s <a href="https://docs.ohsome.org/ohsome-api/v1/">OpenStreatMap API</a> and provides functions to analyze the rich data source of <a href="https://heigit.org/big-spatial-data-analytics-en/ohsome/">OpenStreetMap (OSM) history</a>. See the <a href="https://cran.r-project.org/web/packages/ohsome/vignettes/ohsome.html">vignette</a> for examples.</p>
<p><img src="ohsome.png" height = "400" width="600" alt="map showing Breweries per sq km in Bavaria"></p>
<p><a href="https://cran.r-project.org/package=OlympicRshiny">OlympicRshiny</a> v1.0.0: Implements a <code>Shiny</code> App to visualize Olympic Data from 1896 to 2016 residing in a <a href="https://www.kaggle.com/datasets/heesoo37/120-years-of-olympic-history-athletes-and-results">Kaggle Dataset</a>. Look <a href="https://github.com/Amalan-ConStat/OlympicRshiny">here</a> to get started.</p>
<iframe src="https://amalan-con-stat.shinyapps.io/OlympicRshiny/" data-external="1" width="925px" height="800px">
</iframe>
<p><a href="https://cran.r-project.org/package=whitewater">whitewater</a> v0.1.2: Provides methods for retrieving United States Geological Survey (USGS) water data using sequential and parallel processing. See <a href="https://journal.r-project.org/archive/2021/RJ-2021-048/index.html">Bengtsson (2022)</a> for background on the parallel methods and <a href="https://cran.r-project.org/web/packages/whitewater/readme/README.html">README</a> for examples.</p>
<p><img src="whitewater.png" height = "400" width="600" alt="Map and histogram of peak flow"></p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=birdscanR">birdscanR</a> v0.1.2: Provides functions to extract bird and insect data from <a href="https://swiss-birdradar.com/systems/radar-birdscan-mr1/">Birdscan MR1</a> <code>SQL</code> vertical-looking radar databases, filter, and process the data into Migration Traffic Rates, e.g. #objects per hour and per km, etc. See <a href="https://zenodo.org/record/5734961#.ZCHYfuzML0o">Haest et al. (2021)</a> and <a href="https://onlinelibrary.wiley.com/doi/10.1111/ecog.04025">Schmid et al. (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/birdscanR/vignettes/mtrCalculationWorkflow.html">vignette</a> for examples.</p>
<h3 id="economics">Economics</h3>
<p><a href="https://cran.r-project.org/package=echoice2">echoice2</a> v0.2.3: Implements choice models based on economic theory, including MCMC based estimation prediction, Hierarchical Multinomial Logit and Multiple Discrete-Continuous (Volumetric) models. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S2452261919300024?via%3Dihub">Allenby, Hardt and Rossi (2019)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S0167811622000210?via%3Dihub">Kim, Hardt, Kim and Allenby (2022)</a>, and <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3418383">Hardt and Kurz (2020)</a> for the underlying theory, and the vignettes on <a href="https://cran.r-project.org/web/packages/echoice2/vignettes/Importing_lol_data.html">Importing lists of lists</a> and <a href="https://cran.r-project.org/web/packages/echoice2/vignettes/Modeling_volumetric_demand.html">Volumetric Demand and Conjunctive Screening</a>.</p>
<p><img src="echoice2.png" height = "300" width="500" alt="Density of pizza purchases"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=ODRF">ODRF</a> v0.0.3: Implements oblique decision random random forests as an ensemble of <a href="https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=4d3f466fa7e32ab8f11873778893c38558537975">oblique decision trees</a> which use linear combinations of predictors for partitioning trees. See the <a href="https://cran.r-project.org/web/packages/ODRF/vignettes/Oblique-Decision-Random-Forest.html">vignette</a>.</p>
<p><img src="ODRF.png" height = "400" width="600" alt="Example of an oblique classification tree"></p>
<p><a href="https://cran.r-project.org/package=spinner">spinner</a> v1.1.0: Provides a <code>torch</code> implementation of <a href="https://en.wikipedia.org/wiki/Graph_neural_network">Graph Net architecture</a> allowing different options for message passing and feature embedding. Look <a href="https://rpubs.com/giancarlo_vercellino/spinner">here</a> for examples.</p>
<p><img src="spinner.png" height = "350" width="500" alt="Plot showing performance of model on training and test sets"></p>
<p><a href="https://cran.r-project.org/package=sMTL">sMTL</a> v0.1.0: Implements L0-constrained Multi-Task Learning and domain generalization algorithms which are coded in <code>Julia</code> allowing for fast coordinate descent and local combinatorial search algorithms. See <a href="https://arxiv.org/abs/2212.08697">Loewinger et al. (2022)</a> for details and look <a href="https://rpubs.com/gloewinger/996629">here</a> for an introduction.</p>
<p><a href="https://cran.r-project.org/package=tfevents">tfevents</a> v0.0.2: Provides a convenient way to log scalars, images, audio, and histograms in the <code>tfevent</code> record file format. Logged data can be visualized on the fly using <a href="https://www.tensorflow.org/tensorboard/get_started#:~:text=TensorBoard%20is%20a%20tool%20for,dimensional%20space%2C%20and%20much%20more.">TensorBoard</a>, a web based tool that focuses on visualizing the training progress of machine learning models. Look <a href="https://mlverse.github.io/tfevents/">here</a> for an example.</p>
<p><img src="tfevents.png" height = "400" width="600" alt="tfevents dashboard"></p>
<p><a href="https://cran.r-project.org/package=tidyAML">tidyAML</a> v0.0.1: Implements a simple interface for automatic machine learning that uses the fits <code>tidymodels</code> framework to fit models. Look <a href="https://github.com/spsanderson/tidyAML">here</a> for examples.</p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=deFit">deFit</a> v0.1.2: Provides functions that use numerical optimization to fit first and second order ordinary differential equations to time series data in order to examine the dynamic relationships between variables or the characteristics of a dynamical system. Look <a href="https://github.com/yueqinhu/defit">here</a> for examples.</p>
<p><img src="deFit.png" height = "300" width="500" alt="Plot of second order differential equation fit"></p>
<p><a href="https://cran.r-project.org/package=fitlandr">fitlandr</a> v0.1.0: Provides a toolbox for estimating vector fields from intensive longitudinal data and construct potential landscapes. The vector fields can be estimated with two nonparametric methods: the Multivariate Vector Field Kernel Estimator by <a href="https://www.cambridge.org/core/journals/econometric-theory/article/abs/on-the-functional-estimation-of-multivariate-diffusion-processes/4E79676711B260493964399BE28240D9">Bandi & Moloche (2018)</a> and the Sparse Vector Field Consensus algorithm by <a href="https://www.sciencedirect.com/science/article/abs/pii/S0031320313002410?via%3Dihub">Ma et al. (2013)</a>. The potential landscapes are simulated with the <code>simlandr</code> package of <a href="https://psyarxiv.com/pzva3/">Cui et al. (2021)</a> or with the method of <a href="https://bmcsystbiol.biomedcentral.com/articles/10.1186/1752-0509-5-85">Bhattacharya et al. (2011)</a>. See <a href="https://cran.r-project.org/web/packages/fitlandr/readme/README.html">README</a> for examples.</p>
<p><img src="fitlandr.png" height = "400" width="600" alt="Plot of two dimensional vector field"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=CodelistGenerator">CodelistGenerator</a> v1.0.0: Provides functions to generate a candidate code list for the Observational Medical Outcomes Partnership <a href="https://www.ohdsi.org/data-standardization/">common data model</a> based on string matching. For a given search strategy, a candidate code list will be returned. See the <a href="https://cran.r-project.org/web/packages/CodelistGenerator/vignettes/a01_Introduction_to_CodelistGenerator.html">Introduction</a> and the vignettes on <a href="https://cran.r-project.org/web/packages/CodelistGenerator/vignettes/a02_Candidate_codes_OA.html">Candidate codes</a>, <a href="https://cran.r-project.org/web/packages/CodelistGenerator/vignettes/a03_Options_for_CodelistGenerator.html">Options</a>, and <a href="https://cran.r-project.org/web/packages/CodelistGenerator/vignettes/a04_codelists_for_medications.html">Codelists for medicaitons</a>.</p>
<p><a href="https://cran.r-project.org/package=simaerep">simaerep</a> v0.4.3: Implements bootstrap based simulation methods to detect clinical trials that may be under reporting adverse events. See <a href="https://link.springer.com/article/10.1007/s40264-020-01011-5">Koneswarakantha (2021)</a> for background and <a href="https://cran.r-project.org/web/packages/simaerep/readme/README.html">README</a> for an example.</p>
<p><img src="simaerep.png" height = "400" width="600" alt="Plots showing adverse event reporting"></p>
<h3 id="pharma">Pharma</h3>
<p><a href="https://cran.r-project.org/package=metalite.ae">metalite</a> v0.1.1: Provides A metadata structure for clinical data analysis and reporting based on Analysis Data Model <a href="https://www.cdisc.org/standards/foundational/adam">(ADaM)</a> datasets which simplifies clinical analysis and reporting tool development by defining standardized inputs, outputs, and workflow. See <a href="https://r4csr.org/">Zhang et al. (2022)</a>, the package <a href="https://cran.r-project.org/web/packages/metalite.ae/vignettes/metalite-ae.html">Introduction</a> and the vignettes <a href="https://cran.r-project.org/web/packages/metalite.ae/vignettes/ae-listing.html">AE Listing</a>, <a href="https://cran.r-project.org/web/packages/metalite.ae/vignettes/ae-specific.html">AE Specification</a>, <a href="https://cran.r-project.org/web/packages/metalite.ae/vignettes/ae-summary.html">AE Summary</a>, and <a href="https://cran.r-project.org/web/packages/metalite.ae/vignettes/rate-compare.html">Miettinen and Nurminen Test</a>.
<img src="metalite.png" height = "400" width="600" alt="Diagram of metalite framework"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=gcplyr">gcplyr</a> v1.1.0: Implements tools to import, manipulate and analyze bacterial growth curve data as commonly output by plate readers including for reshaping common plate reader outputs into <em>tidy</em> formats. See <a href="https://cran.r-project.org/web/packages/gcplyr/readme/README.html">README</a> for documentation. There are several vignettes including an <a href="https://cran.r-project.org/web/packages/gcplyr/vignettes/gcplyr.pdf">Introduction</a> and <a href="https://cran.r-project.org/web/packages/gcplyr/vignettes/analyze.pdf">Analyzing data</a> and <a href="https://cran.r-project.org/web/packages/gcplyr/vignettes/noise.pdf">Dealing with noise</a>.</p>
<p><img src="gcplyr.png" height = "500" width="600" alt="Growth curves"></p>
<p><a href="https://cran.r-project.org/package=locaR">locaR</a> v0.1.2: Provides functions to conduct acoustic source localization, as well as organize and check localization data and results. <a href="https://ieeexplore.ieee.org/document/5629353">Cobos et al. (2010)</a> gives details of the algorithms. Vignettes include an <a href="https://cran.r-project.org/web/packages/locaR/vignettes/V3_Intro_to_localize.html">Introduction</a>, <a href="https://cran.r-project.org/web/packages/locaR/vignettes/V2_Detecting_sound_sources.html">Detecting sound sources</a>, and <a href="Introduction to localizeMultiple">localize Multiple</a>.</p>
<p><img src="locaR.gif" height = "350" width="350" alt="Animation of localization method"></p>
<p><a href="https://cran.r-project.org/package=PoolDilutionR">PooldiloutionR</a> v1.0.0: Pool dilution is a isotope tracer technique wherein a biogeochemical pool is artificially enriched with its heavy isotopologue and the gross productive and consumptive fluxes of that pool are quantified. This package calculates gross production and consumption rates from closed-system isotopic pool dilution time series data. See <a href="https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2001GB001448">Fischer and Hedin (2002)</a> for background and the <a href="https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2001GB001448">vignette</a> for examples.</p>
<p><img src="Pool.png" height = "400" width="600" alt="Predictions and observations over time"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=counterfactuals">counterfactuals</a> v0.1.1: Implements a modular R6 interface for counterfacual explanation methods including <a href="https://arxiv.org/abs/2104.07411">Burghmans et al. (2022)</a>, <a href="https://link.springer.com/chapter/10.1007/978-3-030-58112-1_31">Dandl et al. (2020)</a>, and <a href="https://ieeexplore.ieee.org/document/8807255">Wexler et al. (2019)</a>. See the the <a href="https://cran.r-project.org/web/packages/counterfactuals/vignettes/introduction.html">Introduction</a> and the vignettes <a href="https://cran.r-project.org/web/packages/counterfactuals/vignettes/how-to-add-new-cf-methods.html">How to extend the package</a> and <a href="https://cran.r-project.org/web/packages/counterfactuals/vignettes/other_models.html">Other types of models</a>.</p>
<p><img src="counterfactuals.png" height = "500" width="500" alt="Plot of conterfactual surface"></p>
<p><a href="https://cran.r-project.org/package=semfindr">semfindr</a> v0.1.4: Provides functions for sensitivity analysis in structural equation modeling using influence measures and diagnostic plots. It supports the leave-one-out case wise sensitivity analysis of <a href="https://www.tandfonline.com/doi/abs/10.1080/00273171.2011.561068">Pek and MacCallum (2011)</a>. There is an <a href="https://cran.r-project.org/web/packages/semfindr/vignettes/semfindr.html">introduction</a> and three additional vignettes: <a href="https://cran.r-project.org/web/packages/semfindr/vignettes/casewise_scores.html">Approximate Case Influence</a>, <a href="https://cran.r-project.org/web/packages/semfindr/vignettes/selecting_cases.html">Selecting Cases in Rerun</a>, and <a href="https://cran.r-project.org/web/packages/semfindr/vignettes/user_id.html">Use Case IDs</a>.</p>
<p><img src="semfindr.png" height = "400" width="400" alt="Plot of fit measure against generalized Cook's distance"></p>
<p><a href="https://cran.r-project.org/package=stxplore">stxplore</a> v0.1.0: Implements statistical tools for spatio-temporal data exploration, including simple plotting functions, covariance calculations and computations similar to principal component analysis for spatio-temporal data. Look <a href="https://sevvandi.github.io/stxplore/">here</a> for examples and see the vignettes <a href="https://cran.r-project.org/web/packages/stxplore/vignettes/stxplore.html">Exploration using dataframes</a> and <a href="https://cran.r-project.org/web/packages/stxplore/vignettes/stxplore_stars.html">Using stars objects</a>.</p>
<p><img src="stxplore.png" height = "350" width="400" alt="Plot of group means"></p>
<p><a href="https://cran.r-project.org/package=SurrogateRsq">SurrogateRsq</a> v0.2.0: Implements the surrogate R-squared measure for categorical data analysis proposed in <a href="https://bpspsychub.onlinelibrary.wiley.com/doi/10.1111/bmsp.12289">Liu et al. (2022)</a>. See the <a href="https://cran.r-project.org/web/packages/SurrogateRsq/vignettes/JSSpaper.pd">vignette</a>.</p>
<p><img src="SurrogateRsq.png" height = "400" width="500" alt="Diagram of workflow for modeling categorical data"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=setartree">setartree</a> v0.1.0: Implements the forecasting-specific tree-based model proposed by <a href="https://arxiv.org/abs/2211.08661v1">Godahewa et al. (2022)</a> that is particularly suitable for global time series forecasting. Look <a href="https://github.com/rakshitha123/SETAR_Trees">here</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=StructuralDecompose">StructuralDecompose</a> v0.1.1: Provides functions, which perform very well in the presence of significant level shifts, to explain the behavior of a time series by decomposing it into trend, seasonality and residuals. See the short vignettes <a href="https://cran.r-project.org/web/packages/StructuralDecompose/vignettes/Decomposition.html">Decomposition</a> and <a href="https://cran.r-project.org/web/packages/StructuralDecompose/vignettes/Example-Walkthrough.html">Example Walkthrough</a>.</p>
<p><a href="https://cran.r-project.org/package=sufficientForecasting">sufficientForecasting</a> v0.1.0: Implements a sufficient forecasting method for a single time series using many predictors and a possibly nonlinear forecasting function. Assuming that the predictors are driven by some latent factors, the SF first conducts factor analysis and then performs sufficient dimension reduction. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0304407617301616?via%3Dihub">Fan et al. (2017)</a>, <a href="https://academic.oup.com/biomet/article-abstract/109/2/473/6309457?redirectedFrom=fulltext&login=false">Luo et al. (2022)</a>, and <a href="https://www.tandfonline.com/doi/abs/10.1080/07350015.2020.1813589?journalCode=ubes20">Yu et al. (2022)</a> for background and the <a href="https://cran.r-project.org/web/packages/sufficientForecasting/vignettes/SF_vignette.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=tseriesTARMA">tseriesTARMA</a> v0.3-2: Implements routines for nonlinear time series analysis based on <a href="http://amsdottorato.unibo.it/8973/1/Greta_Goracci_tesi_PhD.pdf">Threshold Autoregressive Moving Average models</a> and provides methods for model fitting and forecasting, tests for threshold effects and unit-root tests. See <a href="https://cran.r-project.org/web/packages/tseriesTARMA/readme/README.html">README</a> for examples.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=currr">currr</a> v0..1.2: Implements the family of <code>map()</code> functions with frequent saving of the intermediate results. This enables stopping the evaluation and then restarting it from where you left off by reading the already evaluated work from cache. See <a href="https://cran.r-project.org/web/packages/currr/readme/README.html">README</a> to get started.</p>
<p><img src="currr.gif" height = "350" width="500" alt="Animation showing workflow"></p>
<p><a href="https://cran.r-project.org/package=dataMojo">dataMojo</a> v1.0.0: Implements a grammar of data manipulation with <code>data.table</code> by providing a consistent a series of utility functions that help to solve the most common data manipulation challenges. See the <a href="https://cran.r-project.org/web/packages/dataMojo/vignettes/Intro-dataMojo.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=hexfont">hexfont</a> v0.3.1: Contains all the hex font files from the <a href="https://unifoundry.com/unifont/">GNU Unifont Project</a> compressed by ‘xz’. <a href="https://unifoundry.com/unifont/">GNU Unifont</a> is a duo spaced bitmap font that attempts to cover all the official Unicode glyphs plus several of the artificial scripts in the <a href="http://www.kreativekorp.com/ucsur/">Under-ConScript Unicode Registry</a>. See the <a href="https://cran.r-project.org/web/packages/hexfont/vignettes/hexfont.html">vignette</a>.</p>
<p><img src="hexfont.png" height = "350" width="500" alt="Example of hexfont"></p>
<p><a href="https://cran.r-project.org/package=parabar">parabar</a> v0.10.1: Provides a simple interface in the form of R6 classes for executing tasks in parallel, tracking their progress, and displaying accurate progress bars. See <a href="https://cran.r-project.org/web/packages/parabar/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=rang">rang</a> v0.2.0: Provides tools to resolve the dependency graph of R packages at a specific time point based on the information from various <a href="https://blog.r-hub.io/">R-hub web services</a>. The dependency graph can then be used to reconstruct the R computational environment with <a href="https://rocker-project.org">Rocker</a>. See <a href="https://cran.r-project.org/web/packages/rang/readme/README.html">README</a> and the <a href="https://cran.r-project.org/web/packages/rang/vignettes/faq.html">FAQ</a>.</p>
<p><a href="https://cran.r-project.org/package=tablexlsx">tablexlsx</a> v0.1.0: Provides functions to export data frames to excel workbooks. See the <a href="https://cran.r-project.org/web/packages/tablexlsx/vignettes/aa-examples.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=xmpdf">xmpdf</a> v0.1.3: Provides functions to edit <a href="https://en.wikipedia.org/wiki/Extensible_Metadata_Platform"><code>XMP</code> metadata</a> in a variety of media file formats as well as edit bookmarks and documentation in <code>pdf</code> files. Functions can detect and use a variety of command-line tools to perform these operations including <a href="https://exiftool.org/"><code>exiftool</code></a>, <a href="https://www.ghostscript.com/"><code>ghostscript</code></a>, and <a href="https://gitlab.com/pdftk-java/pdftk"><code>pdftk</code></a>. See the <a href="https://cran.r-project.org/web/packages/xmpdf/vignettes/xmpdf.html">Introduction</a> and the <a href="https://cran.r-project.org/web/packages/xmpdf/vignettes/xmp.html">FAQ</a> vignette.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=animate">animate</a> v0.3.9.4: Implements a web-based graphics device to extend base R graphics functions to support frame-by-frame animation and keyframes animation. Target use cases include real-time animated visualizations, agent-based models, dynamical systems, and animated diagrams. See the <a href="https://cran.r-project.org/web/packages/animate/vignettes/introduction.html">Introduction</a> and the <a href="https://cran.r-project.org/web/packages/animate/vignettes/troubleshooting.html">Q&A</a> vignette.</p>
<p><a href="https://cran.r-project.org/package=Durga">Durga</a> v1.0.0: Implements a system for plotting grouped data effect sizes. compatible with base R methods for combining plots. See <a href="https://www.biorxiv.org/content/10.1101/2023.02.06.526960v1">Khan & McLean (2023)</a> and the <a href="https://cran.r-project.org/web/packages/Durga/vignettes/Durga-intro.html">vignette</a>
for examples.</p>
<p><img src="Durga.png" height = "350" width="500" alt="Plot showing effects of insulin on blood sugar"></p>
<p><a href="https://cran.r-project.org/package=ggrain">ggrain</a> v0.0.3: Extends <code>ggplot2</code> to create raincloud plots. See the <a href="https://cran.r-project.org/web/packages/ggrain/vignettes/ggrain.html">vignette</a>.</p>
<p><img src="ggrain.png" height = "350" width="350" alt="Example of raincloud plot"></p>
<p><a href="https://cran.r-project.org/package=PieGlyph">PieGlyph</a> v0.1.0: Extends <code>ggplot2</code> to replace points in a scatter plot with pie-chart glyphs showing the relative proportions of different categories. There are several vignettes including <a href="https://cran.r-project.org/web/packages/PieGlyph/vignettes/PieGlyph.html">PieGlyph</a>, <a href="https://cran.r-project.org/web/packages/PieGlyph/vignettes/multinomial-classification-example.html">Multinomial Classificatio</a>, and <a href="https://cran.r-project.org/web/packages/PieGlyph/vignettes/time-series-example.html">Time series example</a>.</p>
<p><img src="PieGlyph.png" height = "350" width="500" alt="Time series with covariate information"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/03/28/february-2023-top-40-new-cran-packages/';</script>
January 2023: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/02/28/january-2023-top-40-new-cran-packages/
Tue, 28 Feb 2023 00:00:00 +0000https://rviews.rstudio.com/2023/02/28/january-2023-top-40-new-cran-packages/
<p>One hundred sixty-five new packages made it to CRAN in January. Here are my “Top 40” selections in thirteen categories: Actuarial Statistics, Archaeology, Computational Methods, Ecology, Genomics, Mathematics, Medicine, Machine Learning, Science, Statistics, Time Series, Utilities, Visualization.</p>
<h3 id="actuarial-statistics">Actuarial Statistics</h3>
<p><a href="https://cran.r-project.org/package=actuaRE">actuaRE</a> v0.1.3: Provides functions to fit random effects models using either the hierarchical credibility model alone or combined with a glm or with a Tweedie generalized linear mixed model. See <a href="https://www.tandfonline.com/doi/abs/10.1080/03461238.2022.2161413?journalCode=sact20">Campo & Antonio (2023)</a> for background and the <a href="https://cran.r-project.org/web/packages/actuaRE/vignettes/actuaRE.html">vignette</a> for an example.</p>
<p><img src="actuaRE.png" height = "600" width="400" alt="Drawing of model hierarchy"></p>
<h3 id="archaeology">Archaeology</h3>
<p><a href="https://cran.r-project.org/package=archeoViz">archeoViz</a> v0.2.2: Implements a <code>shiny</code> application for the visualisation, interactive exploration, and web communication of archaeological excavation data. It includes interactive 3D and 2D visualisations, th generation of cross sections and maps, basic spatial analysis methods, and excavation timeline visualisations. There is a short vignette in <a href="https://cran.r-project.org/web/packages/archeoViz/vignettes/archeoViz-vignette.html">English</a> and <a href="https://cran.r-project.org/web/packages/archeoViz/vignettes/archeoViz-vignette-fr.html">French</a>.</p>
<p><img src="archeoViz.svg" height = "500" width="500" alt="Cross section plot showing location of artifacts at various depths"></p>
<p><a href="https://cran.r-project.org/package=shoredate">shoredate</a> v1.0.0: Provides tools for shoreline dating Stone Age sites located on the Norwegian Skagerrak coast using methods presented in <a href="https://www.sciencedirect.com/science/article/pii/S027737912200511X?via%3Dihub">Roalkvam (2023)</a>. See the <a href="https://cran.r-project.org/web/packages/shoredate/vignettes/shoredate.html">vignette</a>.</p>
<p><img src="shoredate.png" height = "600" width="400" alt="Spatial isobases and other plots of shoreline displacement"></p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=em">em</a> v1.0.0: Implements a generic Expectation-Maximization (EM) algorithm within a maximum likelihood framework based on <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/j.2517-6161.1977.tb01600.x">Dempster, Laird, and Rubin (1977)</a>. See the <a href="https://cran.r-project.org/web/packages/em/vignettes/em_intro.pdf">vignette</a> for some theory and examples.</p>
<p><a href="https://cran.r-project.org/package=ROptimus">ROptimus</a> v3.0.0: Implements a general-purpose optimisation engine that supports Monte Carlo optimisation with the Metropolis criterion and acceptance ratio replica exchange Monte Carlo optimization. See the foundational papers <a href="https://aip.scitation.org/doi/10.1063/1.1699114">Metropolis et al. (1953)</a>, <a href="https://academic.oup.com/biomet/article-abstract/57/1/97/284580?redirectedFrom=fulltext&login=false">Hastings (1970)</a>, <a href="https://www.science.org/doi/10.1126/science.220.4598.671">Kirkpatrick et al. (1983)</a> and <a href="https://link.springer.com/article/10.1007/BF00940812">Černý (1985)</a> for background.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=CopernicusMarine">CopernicusMarine</a> v0.0.6: Provides functions to import data on the ocean’s physical and biogeochemical state from <a href="https://data.marine.copernicus.eu">EU Copernicus Marine Service Information</a>. See <a href="https://cran.r-project.org/web/packages/CopernicusMarine/readme/README.html">README</a> to get started.</p>
<p><img src="coper.png" height = "600" width="400" alt="Layered leaflet map of Europe"></p>
<p><a href="https://cran.r-project.org/package=itol.toolkit">itol.toolkit</a> v1.1.0: Provides helper functions to access the <a href="https://itol.embl.de/">Interactive Tree of Life</a> including functions to edit and annotate trees interactively. See the <a href="https://cran.r-project.org/web/packages/itol.toolkit/vignettes/Get_Start.html">vignette</a> to get started.</p>
<p><img src="itool.jpeg" height = "600" width="400" alt="iTool logo"></p>
<p><a href="https://cran.r-project.org/package=rdracor">rdracor</a> v0.7.2: Provides an interface to the Drama Corpora Project <a href="https://dracor.org/documentation/api">(DraCor)</a> API.</p>
<p><img src="rdracor.png" height = "400" width="600" alt="Plot of distribution of plays"></p>
<p><a href="https://cran.r-project.org/package=usdoj">usdoj</a> v1.0.0: Provides functions to fetch data from the U.S Department of Justice <a href="https://www.justice.gov/developer/api-documentation/api_v1">API</a> such as press releases, blog entries, and speeches. Look <a href="https://github.com/rOpenGov/usdoj">here</a> for notes on data structure.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=pastclim">pastclim</a> v1.2.3: Implements methods to extract and manipulate palaeoclimate reconstructions for ecological and anthropological analyses as described in <a href="https://www.biorxiv.org/content/10.1101/2022.05.18.492456v1">Leonardi et al. (2022)</a>. See the <a href="https://cran.r-project.org/web/packages/pastclim/vignettes/a0_pastclim_overview.html">Overview</a> and the vignettes <a href="https://cran.r-project.org/web/packages/pastclim/vignettes/a1_available_datasets.html">available datasets</a> and <a href="https://cran.r-project.org/web/packages/pastclim/vignettes/a2_custom_datasets.html">custom dataset</a>.</p>
<p><img src="pastclim.png" height = "500" width="500" alt="Time series overlaid on world maps"></p>
<p><a href="https://cran.r-project.org/package=PERK">PERK</a> v0.0.9.2: Implements a <code>shiny</code> web application to predict and visualize concentrations of pharmaceuticals in the aqueous environment. See <a href="https://www.ssrn.com/abstract=4306129">Jagadeesan et al. (2022)</a> and the <a href="https://cran.r-project.org/web/packages/PERK/vignettes/PERK-Walkthrough.html">vignette</a> for a walk through.</p>
<p><img src="PERK.png" height = "400" width="500" alt="Predicted concentrations"></p>
<h3 id="gemomics">Gemomics</h3>
<p><a href="https://cran.r-project.org/package=autoGO">autoGO</a> v0.9.1: Implements a framework to enable automated, high quality gene ontology enrichment analysis visualizations and a wrapper for differential expression analysis using the <code>DESeq2</code> package described in <a href="https://genomebiology.biomedcentral.com/articles/10.1186/s13059-014-0550-8">Love et al. (2014)</a>. See the <a href="https://cran.r-project.org/web/packages/autoGO/vignettes/autoGO-tutorial.html">vignette</a>.</p>
<p><img src="autoGO.png" height = "400" width="600" alt="Lollipop plot of 20 most enriched genes"></p>
<p><a href="https://cran.r-project.org/package=phylter">phylter</a> v0.9.6: Provides functions to detect and remove outliers in phylogenomics datasets that build on the <em>Distatis</em> approach described in <a href="https://www.biorxiv.org/content/10.1101/2021.09.08.459421v5">Abdi et al. (2005)</a>. See the <a href="https://cran.r-project.org/web/packages/phylter/vignettes/runphylter.html">vignette</a>.</p>
<p><img src="phylter.png" height = "600" width="400" alt="Flow diagram of the process"></p>
<p><a href="https://cran.r-project.org/package=poolHelper">poolHelper</a> v1.0.0: Provides functions to simulate pooled sequencing data under a variety of conditions, and also evaluate the average absolute difference between allele frequencies computed from genotypes and those computed from pooled data. See <a href="https://www.biorxiv.org/content/10.1101/2023.01.20.524733v1">Carvalho et al. (2022)</a> for the details and the <a href="https://cran.r-project.org/web/packages/poolHelper/vignettes/poolvignette.html">vignette</a> for an introduction to the package.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=BT">BT</a> v0.3: Implements adaptive boosting trees for Poisson distributed response variables, using log-link function. See <a href="https://link.springer.com/book/10.1007/978-3-030-25820-7">Trufin & Denuit (2021)</a>, <a href="https://link.springer.com/book/10.1007/978-3-030-25820-7">Denuit et al. (2019)</a>, and <a href="https://www.tandfonline.com/doi/abs/10.1080/03461238.2022.2037016?journalCode=sact20">Hainaut & Trufin (2022)</a> for background, and the <a href="https://cran.r-project.org/web/packages/BT/vignettes/BT-usage-example.html">vignette</a> for an example.</p>
<p><img src="BT.png" height = "400" width="600" alt="Plots showing performance of a Tweedie model"></p>
<p><a href="https://cran.r-project.org/package=chatgpt">chatgpt</a> v0.1.5: Implements a <a href="https://chat.openai.com/auth/login">ChatGPT</a> coding assistant for the <code>RStudio</code> IDE.</p>
<p><a href="https://cran.r-project.org/package=evreg">evreg</a> v1.0.1: Implements a evidential neural network for the regression model recently introduced in <a href="https://www.techrxiv.org/articles/preprint/Quantifying_Prediction_Uncertainty_in_Regression_using_Random_Fuzzy_Sets_the_ENNreg_model/21791831/1">Denoeux (2023)</a> in which prediction uncertainty is quantified by Gaussian random fuzzy numbers as introduced in <a href="https://www.sciencedirect.com/science/article/abs/pii/S0165011422002457?via%3Dihub">Denoeux (2023)</a>. See the <a href="https://cran.r-project.org/web/packages/evreg/vignettes/Introduction.html">vignette</a>.</p>
<p><img src="evreg.png" height = "450" width="450" alt="Plot of predictions with belief intervals"></p>
<p><a href="https://cran.r-project.org/package=FuzzyDBScan">FuzzyDBScan</a> v0.0.3: Provides an interface to the Fuzzy DBScan clustering algorithm described in <a href="https://link.springer.com/article/10.1007/s00500-016-2435-0">Ienco and Bordogna (2018)</a>. See <a href="https://cran.r-project.org/web/packages/FuzzyDBScan/readme/README.html">README</a> for an example.</p>
<p><img src="fuzzy.png" height = "600" width="600" alt="Plot of irregular clusters"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=rgudhi">rgudhi</a> v0.1.0: Implements and interface to the <code>C++</code> library, <a href="https://gudhi.inria.fr/"><code>GHUDI</code></a> for topological data analysis (TDA) and offers state-of-the-art data structures and algorithms to construct simplicial complexes and compute persistent homology.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=injurytools">injurytools</a> v1.0.1: Provides standardized routines and utilities to simplify the data analysis of sports injuries in order to identify and describe the magnitude of sports injury problems and determine the potential risk factors. See the vignettes <a href="https://cran.r-project.org/web/packages/injurytools/vignettes/estimate-epi-measures.html">estimate-epi-measures</a>, <a href="https://cran.r-project.org/web/packages/injurytools/vignettes/prepare-injury-data.html">prepare-injury-data</a>. and <a href="https://cran.r-project.org/web/packages/injurytools/vignettes/visualize-injury-data.html">visualize-injury-data</a>.</p>
<p><img src="injury.png" height = "400" width="600" alt="Plots of injury risk matirces"></p>
<p><a href="https://cran.r-project.org/package=simIDM">simIDM</a> v0.0.5: Provides functions to simulate oncology trials using an illness - death model. See <a href="https://onlinelibrary.wiley.com/doi/10.1002/sim.8295"> Meller, Beyersmann and Rufibach (2019)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/simIDM/vignettes/quickstart.html">Getting Started</a> and <a href="https://cran.r-project.org/web/packages/simIDM/vignettes/trialplanning.html">Power and Type 1 Error Correlations</a>.</p>
<p><img src="simIDM.png" height = "350" width="450" alt="Diagram of illness-death model"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=gravmagsubs">gravmagsubs</a> v1.0.1: Provides functions to compute the gravitational and magnetic anomalies generated by 3-D vertical rectangular prisms at specific observation points using the method of <a href="http://mr.crossref.org/iPage?doi=10.1190%2F1.1440645">Plouff (1976)</a>. See the <a href="https://cran.r-project.org/web/packages/gravmagsubs/vignettes/demo_vignette.html">vignette</a>.</p>
<p><img src="gravmagsubs.png" height = "400" width="500" alt="Plot of gravity anomalies associated with a prism"></p>
<p><a href="https://cran.r-project.org/package=QurvE">QurvE</a> v1.0: Implements three methods for solving high-throughput analysis of growth curves and fluorescence data: linear regression, growth model fitting, and smooth spline fits. A <code>shiny</code> application provides access to all features without requiring any programming knowledge. There is a <a href="https://cran.r-project.org/web/packages/QurvE/vignettes/shiny_app_manual.html">User Manual</a> and there are vignettes on <a href="https://cran.r-project.org/web/packages/QurvE/vignettes/vignette_fluorescence.html">Flouresence Curve Evaluation</a> and <a href="https://cran.r-project.org/web/packages/QurvE/vignettes/vignette_growth.html">Growth Curve Evaluation</a>.</p>
<p><img src="QurvE.jpeg" height = "400" width="600" alt="Diagram of the internal structure of a grofit object generated by growth.workflow()"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=BCClong">BCClong</a> v1.0.0: Implements a Bayesian consensus clustering (BCC) model for multiple longitudinal features via a generalized linear mixed model that allows simultaneous clustering of mixed-type (e.g., continuous, discrete and categorical) longitudinal features. There are vignettes for <a href="https://cran.r-project.org/web/packages/BCClong/vignettes/ContinuousData.html">continuous</a> and <a href="https://cran.r-project.org/web/packages/BCClong/vignettes/MixedTypeData.html">mixed type</a> data.</p>
<p><img src="BCClong.png" height = "400" width="600" alt="Plots of clusters for continuous data"></p>
<p><a href="https://cran.r-project.org/package=clarify">clarify</a> v0.1.2: Provides functions to perform simulation-based inference as an alternative to the delta method for obtaining valid confidence intervals and p-values for regression post-estimation quantities such as average marginal effects and predictions at representative values. The methodology is described in <a href="https://www.jstor.org/stable/2669316?origin=crossref">King et al. (2000)</a>. See the <a href="https://cran.r-project.org/web/packages/clarify/vignettes/clarify.html">vignette</a> for examples.</p>
<p><img src="clarify.png" height = "400" width="600" alt="Plot of estimated distributions separated by predictor values"></p>
<p><a href="https://cran.r-project.org/package=emplikAUC">emplikAUC</a> v0.3: Provides functions to test hypotheses and construct confidence intervals for AUC (Area Under receiver operating characteristic curve) and pAUC (partial area under ROC curve) using the method described in <a href="https://www.ms.uky.edu/~mai/research/eAUC1.pdf">Zhao, Ding & Zhou </a>.</p>
<p><a href="https://cran.r-project.org/package=jtdm">jtdm</a> v0.1-0: Implements The Joint Trait Distribution Model in a Bayesian framework using conjugate priors to compute joint probabilities and multivariate confidence intervals. See the <a href="https://cran.r-project.org/web/packages/jtdm/vignettes/ORCHAMP_dataset.html">vignette</a>.</p>
<p><img src="jtdm.png" height = "500" width="500" alt="Plot of partial response curves of pairwise CWM trait combinations together with their 95%
credible regions"></p>
<p><a href="https://cran.r-project.org/package=mbreaks">mbreaks</a> v1.0.0: Functions provide comprehensive treatments for estimating, inferring, testing and selecting linear regression models with structural breaks. See <a href="https://www.jstor.org/stable/2998540?origin=crossref">Bai & Perron (1998)</a> for background and the <a href="https://cran.r-project.org/web/packages/mbreaks/vignettes/examples_mbreaks.html">vignette</a> examples.</p>
<p><img src="mbreaks.png" height = "400" width="600" alt="Observed data with breaks"></p>
<p><a href="https://cran.r-project.org/package=sdmTMB">sdmTMB</a> v0.3.0: Implements spatial and spatiotemporal predictive-process GLMMs (Generalized Linear Mixed Effect Models) using <code>TMB</code>, <a href="https://www.r-inla.org/download-install"><code>INLA</code></a>, and the SPDE (Stochastic Partial Differential Equation) approximation to Gaussian random fields. See <a href="https://www.biorxiv.org/content/10.1101/2022.03.24.485545v2">Anderson et al. (2022)</a> for background and the <a href="https://cran.r-project.org/web/packages/sdmTMB/vignettes/model-description.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=snapKrig">snapKrig</a> v0.0.1: Provides functions for geostatistical modeling and kriging with gridded data using spatially separable covariance Kronecker covariance functions. See <a href="https://era.library.ualberta.ca/items/794fa9bb-a13d-4173-b0cc-2a42d940efcc"> Koch, Lele, Lewis (2020)</a> for descriptions of the computational methods and the <a href="https://cran.r-project.org/web/packages/snapKrig/vignettes/snapKrig_introduction.html">vignette</a> for examples.</p>
<p><img src="snapKrig.png" height = "400" width="600" alt="Plot of snapKrig simulation"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=fnets">fnets</a> v0.1.2: Implements methods for network estimation and forecasting of high-dimensional time series exhibiting strong serial and cross-sectional correlations under a factor-adjusted vector autoregressive model. See <a href="https://arxiv.org/abs/2201.06110">Barigozzi et al. (2022)</a> for the methodology and <a href="https://arxiv.org/abs/2301.11675">Owens et al. (2023)</a> for details of the package.</p>
<p><img src="fnets.png" height = "400" width="600" alt="Plot of Granger causal networks"></p>
<p><a href="https://cran.r-project.org/package=MSinference">MSinference</a> v0.0.9: Provides functions to perform multiscale analysis of a nonparametric regression or nonparametric regressions with time series errors. See <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12347">Khismatullina and Vogt (2020)</a>, <a href="https://arxiv.org/abs/2209.10841">Khismatullina and Vogt (2022)</a> and <a href="https://www.sciencedirect.com/science/article/pii/S030440762100155X?via%3Dihub">Khismatullina and Vogt (2023)</a> for the theory and examples, and the <a href="https://cran.r-project.org/web/packages/MSinference/vignettes/MSinference.pdf">vignette</a> to get started.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=datetimeoffset">datetimeoffset</a> v 0.2.1: Provides support for a number of datetime string standards including <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> and <a href="https://opensource.adobe.com/dc-acrobat-sdk-docs/library/pdfmark/">pdfmark</a> and also datetimes with UTC offsets and possibly heterogeneous time zones with up to nanosecond precision. See the package <a href="https://cran.r-project.org/web/packages/datetimeoffset/vignettes/datetimeoffset.html">Introduction</a>.</p>
<p><a href="https://cran.r-project.org/package=mathml">mathml</a> v0.5: Provides functions to translate <code>R</code> expressions to <code>MathML</code> or <code>MathJax</code> so that they can be rendered in <code>rmarkdown</code> documents and <code>shiny</code> applications. See the <a href="https://cran.r-project.org/web/packages/mathml/vignettes/mathml.html">vignette</a></p>
<p><a href="https://cran.r-project.org/package=options">options</a> v0.0.1: Provides a simple mechanisms for defining and interpreting package options, including helper functions for interpreting environment variables, global options, defining default values and more. See the vignettes <a href="https://cran.r-project.org/web/packages/options/vignettes/envvars.html">environment variables</a> and <a href="https://cran.r-project.org/web/packages/options/vignettes/options.html">options</a>.</p>
<p><a href="https://cran.r-project.org/package=parquetize">parquetize</a> v0.5.3: Provides functions to convert<code>csv</code>, <code>RData</code>, <code>rds</code>, <code>RSQLite</code>, <code>json</code>, <code>ndjson</code>, <code>SAS</code>, <code>SPSS</code> and other files to the <a href="https://parquet.apache.org/"><code>Parquet</code></a> columnar storage format. See the <a href="https://cran.r-project.org/web/packages/parquetize/vignettes/aa-conversions.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=scenes">scenes</a> v0.1.0: Provides functions to facilitate switching between <code>shiny</code> UIs depending on the information that is to be passed to the request object. See the vignettes <a href="https://cran.r-project.org/web/packages/scenes/vignettes/actions.html">Creating new actions</a> and <a href="https://cran.r-project.org/web/packages/scenes/vignettes/scenes.html">Changing scenes</a>.</p>
<p><a href="https://cran.r-project.org/package=shiny.fluent">shiny.fluent</a> v0.3.0: Provides <code>shiny</code> components based on the <a href="https://developer.microsoft.com/en-us/fluentui#/">Fluent UI</a> <code>JavaScript</code> library. There are several small vignettes including a <a href="https://cran.r-project.org/web/packages/shiny.fluent/vignettes/st-sales-reps-dashboard.html">Tutorial</a> on creating a full dashboard with <code>shiny</code> and <code>Fluent</code>.</p>
<p><img src="shinyfluent.png" height = "400" width="600" alt="Sample shiny dashboard"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=ggplate">ggplate</a> v0.0.1: Provides functions to create simple plots of biological culture plates as well as microplates which can plot both continuous and discrete values. See <a href="https://cran.r-project.org/web/packages/ggplate/readme/README.htm">README</a> for examples.</p>
<p><img src="ggplate.png" height = "500" width="500" alt="384 Well plate layout"></p>
<p><a href="https://cran.r-project.org/package=plotRCS">plotRCS</a> v0.1.3: Extends <code>ggplot2</code> to draw restricted cubic spline curves from a logistic regression model or a Cox proportional hazards regression model using the method described in <a href="https://link.springer.com/book/10.1007/978-3-319-19425-7">Harrell (2015)</a>. Look <a href="https://link.springer.com/book/10.1007/978-3-319-19425-7">here</a> for examples.</p>
<p><img src="plotRCS.png" height = "450" width="450" alt="Restricted spline plot"></p>
<p><a href="https://cran.r-project.org/package=viscomp">viscomp</a> v1.0.0: Implements several visualization tools for exploring the behavior of the components in a network meta-analysis of multi-component interventions including heat plots of the two-by-two component combinations, leave one component combination out scatter plot, violin plots for specific component combination effects, and density plots for components effects. See the <a href="https://cran.r-project.org/web/packages/viscomp/vignettes/viscomp.html">vignette</a> for examples.</p>
<p><img src="viscomp.png" height = "450" width="450" alt="Violin plots of components"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/02/28/january-2023-top-40-new-cran-packages/';</script>
December 2022: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/01/30/december-2022-top-40-new-cran-paclages/
Mon, 30 Jan 2023 00:00:00 +0000https://rviews.rstudio.com/2023/01/30/december-2022-top-40-new-cran-paclages/
<p>One hundred sixteen new packages stuck to CRAN in December 2022. Here are my “Top 40” selections in thirteen categories: Computational Methods, Data, Ecology, Epidemiology, Genomics, Machine Learning, Mathematics, Medicine, Networks, Signal Processing, Statistics, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=bgw">bgw</a> v0.1.0: Implements the BGW algorithm described by <a href="https://dl.acm.org/doi/10.1145/151271.151279">Bunch, Gay and Welsch (1993)</a> which exploits the special structure of statistical estimation problems within a trust-region-based optimization approach to produce an estimation algorithm that is much more effective than the usual practice of using optimization methods originally developed for general optimization. See the <a href="https://cran.r-project.org/web/packages/bgw/vignettes/bgw-vignette.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=GPArotateDF">GPArotateDF</a> v2022.12-1: Provides functions for derivative-free gradient projection algorithms for factor rotation. See <a href="https://link.springer.com/article/10.1007/BF02295647">Jennrich (2004)</a> and <a href="https://journals.sagepub.com/doi/10.1177/0013164404272507">Bernaards and Jennrich (2005)</a> for the theory, and the <a href="https://cran.r-project.org/web/packages/GPArotateDF/vignettes/GPArotateDF.pdf">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/src/contrib/Archive/Mestim">Mestim</a> v0.2.1: Implements a flexible framework for estimating the variance-covariance matrix of parameters by computing the empirical sandwich variance. See <a href="https://www.taylorfrancis.com/books/mono/10.1201/9780429192692/dynamic-treatment-regimes-anastasios-tsiatis-marie-davidian-shannon-holloway-eric-laber">Tsiatis et al. (2019)</a> for background and the <a href="https://cran.r-project.org/web/packages/Mestim/vignettes/intro-vignette.html">vignette</a> for some theory and examples.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=dafishr">dafishr</a> v1.0.0: Provides functions to download, clean and analyse raw Vessel Monitoring System, VMS, data from Mexican government. See the <a href="https://cran.r-project.org/web/packages/dafishr/vignettes/dafisr.html">vignette</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=hcidata">hcidata</a> v0.1.0: Provides a collection of datasets of human-computer interaction (HCI) experiments. Each dataset is from an HCI paper, with all fields described and the original publication linked. The datasets sources include <a href="https://dl.acm.org/doi/10.1145/3490493">Bergström et al. (2022)</a>, <a href="https://dl.acm.org/doi/10.1145/3489849.3489853">Dalsgaard et al. (2021)</a>, <a href="https://dl.acm.org/doi/10.1145/3338286.3340115">Larsen et al. (2019)</a>, <a href="https://dl.acm.org/doi/10.1145/3290605.3300676">Lilija et al. (2019)</a>, <a href="https://dl.acm.org/doi/10.1145/2470654.2481307">Pohl and Murray-Smith (2013)</a>, and <a href="https://www.frontiersin.org/articles/10.3389/frvir.2022.719506/full">Pohl and Mottelson (2022)</a>.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=bamm">bamm</a> v0.4.3: Implements species distribution models as a function of biotic and movement factors. See <a href="https://arxiv.org/abs/2212.06308">Soberón and Osorio-Olvera (2022)</a> for the theoretical background and the <a href="https://cran.r-project.org/web/packages/bamm/vignettes/bam.html">vignette</a> for examples.</p>
<p><img src="bamm.png" height = "350" width="350" alt="Map showing the geographic clusters for a species that can travel two steps per unit time"></p>
<p><a href="https://cran.r-project.org/package=gadget3">gadget3</a> v0.8-4: Provides a framework for creating marine ecosystem models that generates<code>R</code> or <code>C++</code> code which can then be optimized using the <code>TMB</code> package and standard tools. See <a href="https://www.jstatsoft.org/article/view/v070i05">Kristensen et al. (2016)</a> and <a href="https://core.ac.uk/download/pdf/225936648.pdf">Begley & Howell (2004)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/gadget3/vignettes/model-debugging.html">Model Debugging</a>, <a href="https://cran.r-project.org/web/packages/gadget3/vignettes/model_structure.html">Model Structure</a>, and <a href="https://cran.r-project.org/web/packages/gadget3/vignettes/writing_actions.html">Writing G3 Actions</a>.</p>
<h3 id="epidemiology">Epidemiology</h3>
<p><a href="https://cran.r-project.org/package=finalsize">finalsize</a> v0.1: Provides functions to calculate the final size of a susceptible-infectious-recovered epidemic in a population with demographic variation in contact patterns and susceptibility to disease. See <a href="https://link.springer.com/article/10.1007/s11538-012-9749-6">Miller (2012)</a> for details. Additionally, there is an <a href="https://cran.r-project.org/web/packages/finalsize/vignettes/finalsize.html">Introduction</a> and vignettes on modeling <a href="https://cran.r-project.org/web/packages/finalsize/vignettes/uncertainty_params.html">uncertainty in R0</a> and modeling <a href="https://cran.r-project.org/web/packages/finalsize/vignettes/varying_susceptibility.html">heterogeneous susceptibility</a>.</p>
<p><img src="finalsize.png" height = "400" width="460" alt="Plot of % infected by age group"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=betaclust">betaclust</a> v1.0.0: Implements the family of novel beta mixture models developed by <a href="https://arxiv.org/abs/2211.01938v1">Majumdar et al. (2022)</a> to appositely model the beta-valued cytosine-guanine dinucleotide (CpG) sites, to objectively identify methylation state thresholds, and to identify the differentially methylated CpG (DMC) sites using a model-based clustering approach. See the <a href="https://cran.r-project.org/web/packages/betaclust/vignettes/vignettes.html">vignette</a>.</p>
<p><img src="betaclust.png" height = "400" width="600" alt="Plot of kernel density estimates"></p>
<p><a href="https://cran.r-project.org/package=plasma">plasma</a> v0.9.21: Implements tools for supervised analyses of incomplete, overlapping multiomics datasets. Functions apply partial least squares in multiple steps to find models that predict survival outcomes. See the vignettes on <a href="Contains tools for supervised analyses of incomplete, overlapping multiomics datasets. Applies partial least squares in multiple steps to find models that predict survival outcomes.">Interpretation</a> and <a href="https://cran.r-project.org/web/packages/plasma/vignettes/plasma.pdf">Partial Least Squares</a>.</p>
<p><img src="plasma.png" height = "400" width="600" alt=" Distribution of standardized feature weights in the final model, by data set"></p>
<p><a href="https://CRAN.R-project.org/package=POMS">POMS</a> v1.0.1: Provides code to identify functional enrichments across diverse taxa in phylogenetic tree, particularly where these taxa differ in abundance across samples in a non-random pattern. See <a href="https://academic.oup.com/bioinformatics/article/38/22/5055/6731923?login=false">Douglas et al. (2022)</a> for background and look <a href="https://github.com/gavinmdouglas/POMS/wiki">here</a> for documentation.</p>
<p><img src="POMS.png" height = "400" width="400" alt="Circular tree plot"></p>
<p><a href="https://cran.r-project.org/package=vivaldi">vivaldi</a> v1.0.0: Provides functions to analyze minor alleles of viral genomes from sequencing data of viral genomes in Illumina vcf files. See the <a href="https://cran.r-project.org/web/packages/vivaldi/vignettes/vignette.html">vignette</a>.</p>
<p><img src="vivaldi.png" height = "400" width="600" alt="Plot of SNV locations."></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=arf">arf</a> v0.1.2: Implements adversarial random forests, an iterative algorithm that recursively partition data into fully factorized leaves, where features are jointly independent. See <a href="https://arxiv.org/abs/2205.09435">Watson et al. (2022)</a> for details and the vignette on <a href="https://cran.r-project.org/web/packages/arf/vignettes/vignette.html">Density Estimation</a>.</p>
<p><img src="arf.png" height = "400" width="600" alt="Plot for visual assessment of density estimation"></p>
<p><a href="https://cran.r-project.org/package=correctR">correctR</a> Provides corrected test statistics for cases when samples are not independent, such as when classification accuracy values are obtained over resamples or through k-fold cross-validation, as proposed by <a href="https://link.springer.com/article/10.1023/A:1024068626366">Nadeau and Bengio (2003)</a> and presented in <a href="https://link.springer.com/chapter/10.1007/978-3-540-24775-3_3">Bouckaert and Frank (2004)</a>. See the <a href="https://cran.r-project.org/web/packages/correctR/vignettes/correctR.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=HTT">HTT</a> v0.1.1: Implements a novel decision tree algorithm in the hypothesis testing framework that examines the distribution difference between two child nodes over all possible binary partitions. The test statistic enables the algorithm to better detect complex structure and not only the mean difference. See the <a href="https://cran.r-project.org/web/packages/HTT/vignettes/Intro.html">vignette</a></p>
<p><img src="HTT.png" height = "400" width="400" alt="Decision Tree"></p>
<p><a href="https://cran.r-project.org/package=janus">janus</a> v1.0.0: Implements a <code>tensorflow</code>based, deep-neural network recommending system with coarse-to-fine optimization. Look <a href="https://rpubs.com/giancarlo_vercellino/janus">here</a> for an introduction.</p>
<p><a href="https://cran.r-project.org/package=reservr">reservr</a> v0.0.1: Provides functions to fit distributions and neural networks to censored and truncated data. See <a href="https://cran.r-project.org/web/packages/reservr/vignettes/tensorflow.html">Bücher & Rosenstock (2022)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/reservr/vignettes/distributions.html">Working with Distributions</a> and <a href="https://cran.r-project.org/web/packages/reservr/vignettes/distributions.html">TensorFlow Integration</a>.</p>
<p><img src="reservr.png" height = "400" width="400" alt="Plots of distributions and hazard functions"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=qspray">qspray</a> v0.1.1: Provides functions for the symbolic calculation and evaluation of multivariate polynomials with rational coefficients. See <a href="https://cran.r-project.org/web/packages/qspray/readme/README.html">README</a> for an example.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=cstime">cstime</a> v2022.11.22: Provides consistent time conversion functions for public health purposes including conversions between date, ISO week, ISO yearweek, ISO year, calendar month/year, season, and season week. There is an <a href="https://cran.r-project.org/web/packages/cstime/vignettes/cstime.html">Introduction</a> and there are additional vignettes <a href="https://cran.r-project.org/web/packages/cstime/vignettes/date_conversion.html">Date, year, week conversion</a> and <a href="https://cran.r-project.org/web/packages/cstime/vignettes/season.html">Season week</a>.</p>
<p><img src="cstime.png" height = "400" width="400" alt="Plot of iso week vs season week"></p>
<p><a href="https://cran.r-project.org/package=GNGTools">GNGTools</a> v1.0.0: Implements a Go/No-Go decision-making framework based on Bayesian posterior probabilities linked to the target product profile. See the <a href="https://cran.r-project.org/web/packages/GNGTools/vignettes/GNGVignette.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=oncomsm">oncomsm</a> v0.1.2: Implements methods to fit a parametric Bayesian multi-state model to tumor response data. The model can be used to sample from the predictive distribution, to impute missing data, and to calculate probability of success for custom decision criteria during an ongoing trial. See the vignettes <a href="https://cran.r-project.org/web/packages/oncomsm/vignettes/avoiding-bias.html">avoiding-bias</a>, <a href="https://cran.r-project.org/web/packages/oncomsm/vignettes/oncomsm.html">oncomsm</a>, and <a href="https://cran.r-project.org/web/packages/oncomsm/vignettes/prior-choice.html">prior-choice</a>.</p>
<p><img src="oncomsm.png" height = "400" width="600" alt="Survival curves for multistate model"></p>
<p><a href="https://cran.r-project.org/package=REDCapDM">REDCapDM</a> v0.1.0: Provides functions to to read and manage <a href="https://projectredcap.org/">REDCap</a> data and identify missing or extreme values. See the <a href="https://cran.r-project.org/web/packages/REDCapDM/vignettes/REDCapDM.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=sitepickR">sitePickR</a> v0.0.1: Provides functions to perform a two-level process to select a representative sample of sites for a prospective study such as a randomized controlled trial where the possibility of an initially selected site may not want to participate is anticipated. See <a href="http://www.math.helsinki.fi/msm/banocoss/Deville_Tille_2004.pdf">Deville & Tillé (2004)</a> and <a href="https://www150.statcan.gc.ca/n1/en/pub/12-001-x/2011002/article/11609-eng.pdf?st=5-sx8Q8n">Tillé (2011)</a> for background on the method employed and the <a href="https://cran.r-project.org/web/packages/sitepickR/vignettes/sitepickR-demo.html">vignette</a> for a demo.</p>
<p><img src="sitePickR.png" height = "400" width="600" alt="Standardized mean difference curves for multiple sites"></p>
<h3 id="networks">Networks</h3>
<p><a href="https://cran.r-project.org/package=metanetwork">metanetwork</a> v0.7.0: Provides a toolbox to represent large trophic networks in space or time across aggregation levels. The layout algorithm uses dimension reduction on a diffusion graph kernel and trophic levels. Look <a href="https://marcohlmann.github.io/metanetwork/">here</a> for examples.</p>
<p><img src="metanetwork.png" height = "450" width="600" alt="Example of network layout"></p>
<p><a href="https://cran.r-project.org/package=oddnet">oddnet</a> v0.1.0: Implements a feature-based method to identify anomalies in dynamic, temporal networks. See <a href="https://arxiv.org/abs/2210.07407">Kandanaarachchi & Hyndman (2022)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/oddnet/vignettes/oddnet.html">vignette</a> for an example.</p>
<p><img src="oddnet.png" height = "350" width="500" alt="Plot showing how degree distribute picks out an anomaly"></p>
<h3 id="signal-processing">Signal Processing</h3>
<p><a href="https://cran.r-project.org/package=ohun">ohun</a> v0.1.0: Provides functions to facilitates the automatic detection of acoustic signals, including functions to diagnose and optimize the performance of detection routines. See <a href="https://www.aircconline.com/ijdkp/V5N2/5215ijdkp01.pdf">Hossin & Sulaiman (2015)</a> for background and the <a href="https://cran.r-project.org/web/packages/ohun/vignettes/ohun.html">vignette</a> for examples.</p>
<p><img src="ohun.jpeg" height = "400" width="600" alt="Whitewave spectogram"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=gmvjoint">gmvjoint</a> v0.1.0: Implements an EM algorithm for fitting joint survival and glm models of longitudinal data. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S016794731400334X?via%3Dihub">Bernhardt (2015)</a> for background and <a href="https://cran.r-project.org/web/packages/gmvjoint/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=hdcate">hdcate</a> v0.1.0: Implements a two-step double-robust method to estimate the conditional average treatment effects (CATE) with potentially high-dimensional covariates as described in <a href="https://www.tandfonline.com/doi/abs/10.1080/07350015.2020.1811102?journalCode=ubes20">Fan et al. (2022)</a>. See the <a href="https://cran.r-project.org/web/packages/hdcate/vignettes/user_manual.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=jointVIP">jointVIP</a> v0.1.1: Implements joint variance importance plots to assist with variable selection and parameter tuning. See <a href="https://arxiv.org/abs/2301.09754">by Liao et al. (2023)</a> for background. There is a <a href="https://cran.r-project.org/web/packages/jointVIP/vignettes/jointVIP.html">Getting Started Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/jointVIP/vignettes/additional_options.html">Options</a>.</p>
<p><img src="jointVIP.png" height = "400" width="400" alt="Joint Variable Importance Plot"></p>
<p><a href="https://cran.r-project.org/package=nieve">nieve</a> v0.1.1: Provides utility functions and objects for extreme value analysis including probability functions with their exact derivatives and transformations exchanging the two parameterizations of peaks over threshold models. See the <a href="https://cran.r-project.org/web/packages/nieve/vignettes/nieve.pdf">vignette</a>.</p>
<p><img src="nieve.png" height = "400" width="600" alt="Plot of block maxima by aggregation of the Poisson-GP"></p>
<p><a href="https://cran.r-project.org/package=RelDists">RelDists</a> v1.0.0: Provides functions for parameter estimation and linear regression models for the reliability distribution families reviewed by <a href="https://www.sciencedirect.com/science/article/abs/pii/S0951832013003074?via%3Dihub">Almalki & Nadarajah (2014)</a>. Generalized Additive Models are used for location, scale and shape. See <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/j.1467-9876.2005.00510.x">Rigby & Stasinopoulos (2005)</a>. There are vignettes on the [FWE]() and <a href="https://cran.r-project.org/web/packages/RelDists/vignettes/OW_distribution.html">OQ</a> distributions.</p>
<p><img src="RelDists.png" height = "400" width="600" alt="Plot of Flexible Weibull Distribution"></p>
<p><a href="https://cran.r-project.org/package=ridgetorus">ridgetorus</a> v1.0.1: Implements Principal Component Analysis (PCA) on the torus via density ridge estimation, and includes functions for evaluating, fitting, and sampling these models. See <a href="https://arxiv.org/abs/2212.10856"> García-Portugués and Prieto-Tirado (2022)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/ridgetorus/vignettes/ridgetorus.html">vignette</a> for examples.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://CRAN.R-project.org/package=dataset">dataset</a> v0.2.0: Implements a subjective interpretation of the <a href="https://www.w3.org/TR/vocab-data-cube/">W3C DataSet recommendation</a> and the datacube model, which relevant to the global Statistical Data and Metadata eXchange standards, the <a href="https://www.dublincore.org/specifications/dublin-core/dcmi-terms/">Dublin Core</a>, and the <a href="https://support.datacite.org/docs/datacite-metadata-schema-44/">DataCite</a> standards preferred by European open science repositories to improve the findability, accessibility, interoperability and reusability of the datasets. There are several vignettes including <a href="https://cran.r-project.org/web/packages/dataset/vignettes/motivation.html">Motivation</a> and <a href="https://cran.r-project.org/web/packages/dataset/vignettes/metadata.html">Datasets with FAIR Metadata</a>.</p>
<p><a href="https://cran.r-project.org/package=nlmixr2rpt">nlmixr2rpt</a> v0.1.0: provides functions to generate reporting workflows around <code>nlmixr2</code> analyses with outputs in Word and PowerPoint including functions to specify figures, tables and report structure in a user-definable <code>YAML</code> file. See the vignettes <a href="https://cran.r-project.org/web/packages/nlmixr2rpt/vignettes/Accessing_Figures_and_Tables.html">Accessing Figures and Tables</a> and <a href="https://cran.r-project.org/web/packages/nlmixr2rpt/vignettes/Reporting_nlmixr_Fit_Results.html">Reporting nlmixr2 Fit Results</a>.</p>
<p><a href="https://cran.r-project.org/package=qtwAcademic">qtwAcademic</a> v2022.12.13: Provides <code>Quarto</code> website templates commonly used by academics including templates for personal websites and course/workshop websites. There is an <a href="https://cran.r-project.org/web/packages/qtwAcademic/vignettes/qtwAcademic.html">Intraduction</a> and there are vignettes for <a href="https://cran.r-project.org/web/packages/qtwAcademic/vignettes/template_course.html">workshop</a> and <a href="https://cran.r-project.org/web/packages/qtwAcademic/vignettes/template_personal.html">personal</a> websites.</p>
<p><a href="https://cran.r-project.org/package=r2social">r2social</a> v1.0: Provides <code>JavaScript</code> and <code>CSS</code> styles to allow easy incorporation of various social media elements in <code>shiny</code> applications, dashboards and <code>rmarkdown</code> documents. The elements include share buttons, connect with us buttons, and hyperlink buttons. See the <a href="https://cran.r-project.org/web/packages/r2social/vignettes/introduction_r2social.html">vignette</a>.</p>
<p><img src="r2social.gif" height = "400" width="600" alt="Example of page with hyperlink buttons"></p>
<p><a href="https://cran.r-project.org/package=rworkflows">rworkflows</a> v0.99.5: Implements functions for the continuous integration for R packages, automated testing, website building, and containerised deployment. See the vignettes <a href="https://cran.r-project.org/web/packages/rworkflows/vignettes/depgraph.html">depgraph</a>, <a href="https://cran.r-project.org/web/packages/rworkflows/vignettes/docker.html">docker</a>, <a href="https://cran.r-project.org/web/packages/rworkflows/vignettes/repos.html">repositories report</a>, and <a href="https://cran.r-project.org/web/packages/rworkflows/vignettes/rworkflows.html">rworlflows</a>.</p>
<p><img src="rworkflows.png" height = "700" width="700" alt="Package dependency graph"></p>
<p><a href="https://CRAN.R-project.org/package=shinyDatetimePickers">shinyDatetimePicker</a> v1.0.0: Provides three types of datetime pickers for usage in a <code>shiny</code> UI. See <a href="https://cran.r-project.org/web/packages/shinyDatetimePickers/readme/README.html">README</a> for examples.</p>
<p><img src="shinyDatetimePickers.gif" height = "400" width="600" alt="Package dependency graph"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://CRAN.R-project.org/package=ddplot">ddplot</a> v0.0.1: Implements an API to allow users to create <a href="https://d3js.org/"><code>D3</code></a> based SVG plots using the <a href="https://rstudio.github.io/r2d3/"><code>r2d3</code></a> library. See the <a href="https://cran.r-project.org/web/packages/ddplot/vignettes/Start.html">vignette</a>.</p>
<p><img src="ddplot.png" height = "400" width="600" alt="Colorful stack area plot"></p>
<p><a href="https://cran.r-project.org/package=swipeR">swipeR</a> v0.1.0: Provides tools to create carousels using the <code>JavaScript</code> library <code>Swiper</code> and <code>htmlwidgets</code>. Carousels can be displayed in the RStudio viewer pane, in <code>Shiny</code> applications and in <code>rmarkdown</code> documents. See <a href="https://cran.r-project.org/web/packages/swipeR/readme/README.html">README</a> for examples.</p>
<p><img src="swipeR.gif" height = "450" width="600" alt="Carousel of ggplots"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/01/30/december-2022-top-40-new-cran-paclages/';</script>
Some R Conferences for 2023
https://rviews.rstudio.com/2023/01/18/some-r-conferences-for-2023/
Wed, 18 Jan 2023 00:00:00 +0000https://rviews.rstudio.com/2023/01/18/some-r-conferences-for-2023/
<div class="figure">
<img src="img.png" alt="" />
<p class="caption">A collage of various conference logos, including posit conf, NICAR, Shiny Conf, Shiny in Production, and more.</p>
</div>
<p>Happy January! Below, we share a list of upcoming conferences that either focus on the R programming language or showcase its use in the field. If we have missed your conference, please leave a comment with the details. We will update our list as we receive more information.</p>
<p><strong>March</strong></p>
<p>(2 - 5) Nashville, TN - <a href="https://www.ire.org/training/conferences/">NICAR</a> is well attended by data journalists. Matthew Ericson, Assistant Managing Editor at The New York Times, noted the prevalence of the R programming language at the conference:</p>
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">At <a href="https://twitter.com/hashtag/nicar22?src=hash&ref_src=twsrc%5Etfw">#nicar22</a> and struck by how prevalent R has become in data journalism, so I thought it would be fun to see how the hands-on classes have changed since my early NICAR days. Found a PDF of the 2004 NICAR schedule and totaled up the types of classes then and now. <a href="https://t.co/XRM7y1D6Sb">pic.twitter.com/XRM7y1D6Sb</a></p>— Matthew Ericson (@mericson) <a href="https://twitter.com/mericson/status/1500148424083222531?ref_src=twsrc%5Etfw">March 5, 2022</a></blockquote>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<p>(15 - 17) online and <em>free</em> - <a href="https://shinyconf.appsilon.com/">ShinyConf 2023 by Appsilon</a> will bring together members from the global community of Shiny developers to learn, network, and share.</p>
<p><strong>May</strong></p>
<p>(19 - 20) Chicago, IL - <a href="https://www.rinfinance.com/">R / Finance</a> has talks and sessions on various quantitative finance topics, including portfolio construction, statistics, quant ideas, and more.</p>
<p><strong>June</strong></p>
<p>(6 - 9) online - <a href="https://r-medicine.org/">R / Medicine</a> promotes the development and use of R-based tools to improve clinical research and practice.</p>
<p>(8 - 9) Universität Zürich, Switzerland - <a href="https://www.psychoco.org">Psychoco 2023</a> aims to bring together researchers from statistics, psychology, and related disciplines working on modern techniques for the analysis of data from psychology and the social sciences.</p>
<p>(21 - 23) Avignon, France - <a href="https://rr2023.sciencesconf.org/">Rencontres R 2023</a>, supported by la Société Française de Statistique (SFdS), offers the French-speaking community a place to exchange and share ideas on using R software in all disciplines.</p>
<p><strong>August</strong></p>
<p>(2 - 4) Boston, MA - <a href="https://bioconductor.org/">BioConductor</a> provides an opportunity to learn about developments within and beyond the Bioconductor project.</p>
<p>(5 - 10) Toronto, Canada - <a href="https://ww2.amstat.org/meetings/jsm/2023/">JSM</a> is one of the largest statistical events in the world and will likely feature many R-related talks.</p>
<p>( 19 ) Seattle, WA - <a href="https://cascadiarconf.com/">Cascadia R Conf</a> is an R conference serving the Pacific Northwest.</p>
<p><strong>September</strong></p>
<p>(17 - 20) Chicago, IL / hybrid - <a href="https://posit.co/conference/">posit::conf(2023)</a>, Posit’s annual conference, will be at the Hyatt Regency Chicago. We can’t wait to see you there!</p>
<p><strong>October</strong></p>
<p>(12 - 13) Newcastle Upon Tyne, UK - <a href="https://shiny-in-production.jumpingrivers.com/">Shiny in Production</a> will delve into the world of Shiny and other web-based R packages.</p>
<p>What an exciting season ahead! Hope to see you at one (or many) of these events.</p>
<script>window.location.href='https://rviews.rstudio.com/2023/01/18/some-r-conferences-for-2023/';</script>
November 2022: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2023/01/03/november-2022-top-40-new-cran-packages/
Tue, 03 Jan 2023 00:00:00 +0000https://rviews.rstudio.com/2023/01/03/november-2022-top-40-new-cran-packages/
<p>One hundred sixty-seven new packages made it to CRAN in November: Here are my “Top 40” selections in fourteen categories: Climate Modeling: Computational Methods, Data, Ecology, Epidemiology, Genomics, Machine Learning, Mathematics, Networks, Pharma, Statistics, Time Series, Utilities, and Visualization.</p>
<h2 id="climate-modeling">Climate Modeling</h2>
<p><a href="https://CRAN.R-project.org/package=gtfs2emis">gtfs2emis</a> v0.1.0: Implements a bottom up model to estimate the emission levels of public transport systems based on <a href="https://gtfs.org/">General Transit Feed Specification</a> data. Functions estimate several pollutants at high spatial and temporal resolutions. See <a href="https://osf.io/8m2cy/">Viera et al</a> for background. There is a <a href="https://cran.r-project.org/web/packages/gtfs2emis/vignettes/gtfs2emis_intro_vignette.html">Getting Started Guide</a>, and vignettes on <a href="https://cran.r-project.org/web/packages/gtfs2emis/vignettes/gtfs2emis_emission_factor.html">Emission Factors</a> and <a href="https://cran.r-project.org/web/packages/gtfs2emis/vignettes/gtfs2emis_fleet_data.html">Preparing Data</a>.</p>
<p><img src="gfts.png" height = "400" width="400" alt="Spatial distribution of traffic speeds for Dublin, Ireland"></p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=jmatrix">jmatrix</a> v1.1: A mainly instrumental package that allows other packages with cores written in <code>C++</code> to read, write and manipulate matrices in a binary format to mitigate memory issues. See the <a href="https://cran.r-project.org/web/packages/jmatrix/vignettes/jmatrix.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=lazyNumbers">lazyNumbers</a> v1.2.1: Implements <em>lazy numbers</em>, a new number type whose arithmetic is exact, contrary to ordinary floating-point arithmetic. The lazy numbers are implemented in <code>C++</code> with the <a href="https://www.cgal.org/"><code>CGAL</code> library</a>. See <a href="https://cran.r-project.org/web/packages/lazyNumbers/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=miesmuschel">miesmuschel</a> v0.0.2: Provides optimization algorithms and functions that can be used to manually construct specialized optimization loops including the mixed integer evolution strategy as described in <a href="https://direct.mit.edu/evco/article-abstract/21/1/29/933/Mixed-Integer-Evolution-Strategies-for-Parameter?redirectedFrom=fulltext">Li et al. (2013)</a> and the multi-objective optimization algorithms NSGA-II described in <a href="https://ieeexplore.ieee.org/document/996017">Deb et al. (2002)</a>. See <a href="https://cran.r-project.org/web/packages/miesmuschel/readme/README.html">README</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=mlr3mbo">mlr3mbo</a> v0.1.1: Implements a flexible approach to Bayesian optimization that includes both ready-to-use optimization algorithms as well as fundamental building blocks to construct custom algorithms. See <a href="https://link.springer.com/article/10.1023/A:1008306431147">Jones et al. (1998)</a>, <a href="https://link.springer.com/article/10.1023/A:1008306431147">Knowles (2006)</a>, and <a href="https://link.springer.com/chapter/10.1007/978-3-540-87700-4_78">Ponweiser et al. (2008)</a> for examples of ready to use optimization algorithms and the <a href="https://cran.r-project.org/web/packages/mlr3mbo/vignettes/mlr3mbo.html">vignette</a> for examples.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=googletraffic">googletraffic</a> v0.1.1: Allows users to create geographically referenced traffic data from the <a href="https://developers.google.com/maps/documentation/javascript/examples/layer-traffic">Google Maps JavaScript API</a>. Look <a href="https://dime-worldbank.github.io/googletraffic/">here</a> for information to get started.</p>
<p><img src="googletraffic.jpeg" height = "600" width="400" alt="Traffic map of Manhattan"></p>
<p><a href="https://cran.r-project.org/package=IPEDS">IPEDS</a> v0.1.1: Implements an interface to the US <a href="https://nces.ed.gov/ipeds/use-the-data">Post-Secondary Institution Statistics for 2020</a> which contains information on post-secondary institutions, students, faculty, demographics, financial aid, educational and recreational offerings, and completions. See the <a href="https://cran.r-project.org/web/packages/IPEDS/vignettes/IPEDS-vignette.html">vignette</a>.</p>
<p><img src="IPEDS.png" height = "400" width="500" alt="Scatter plot of student diversity vs. staff diversity in New England institutions"></p>
<p><a href="https://cran.r-project.org/package=npi">npi</a> v0.2.0: Provides access the US <a href="https://npiregistry.cms.hhs.gov/api/">National Provider Identifier Registry API</a> which contains administrative data linked to a specific individual or organizational healthcare providers. There is an <a href="https://cran.r-project.org/web/packages/npi/vignettes/npi.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/npi/vignettes/advanced-use.html">Advanced Use</a>.</p>
<p><a href="https://cran.r-project.org/package=rfars">rfars</a> v0.2.0: Implements an interface to the US <a href="https://cdan.dot.gov/query">Fatality Analysis Reporting System</a>. See the vignettes <a href="https://cran.r-project.org/web/packages/rfars/vignettes/Crash_Sequences.html">Crash Sequences</a> and <a href="img src="googletraffic.png" height = "600" width="400" alt="Traffic map of Manhattan"">Rural Roads</a>.</p>
<p><img src="rfars.png" height = "600" width="400" alt="Bar charts of crash types"></p>
<p><a href="https://cran.r-project.org/package=tidyDisasters">tidyDisasters</a> v0.1.1: Provides a queryable data set that unites information from three complementary resources: Belgium’s Centre for Research on the Epidemiology of Disasters <a href="https://www.cred.be/">EMDAT</a>, the US National Consortium for the Study of Terrorism <a href="https://www.start.umd.edu/">GTD</a>, and the US Federal Emergency Management Agency <a href="https://www.fema.gov/openfema-data-page/disaster-declarations-summaries-v2">FEMA</a>. There is a brief <a href="https://cran.r-project.org/web/packages/tidyDisasters/vignettes/basic_database_example_20221107.html">User Guide</a>.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=et.nwfva">et.nwfva</a> v0.1.1: Implements a forest management tool developed by the Northwest German Forest Research Institute (<a href="https://goettingen-campus.de/nw-fva">NW-FVA</a>) for the five main commercial tree species oak, beech, spruce, Douglas-fir and pine for northwestern Germany. See <a href="https://zenodo.org/record/6827728#.Y681suzML0o">Albert et al (2022)</a> for background and the vignettes: <a href="https://cran.r-project.org/web/packages/et.nwfva/vignettes/beispiele.html">Beispiele</a>, <a href="https://cran.r-project.org/web/packages/et.nwfva/vignettes/nutzerhinweise.html">Nutzerhinweise zum Geleit</a>, and <a href="https://cran.r-project.org/web/packages/et.nwfva/vignettes/vergleich_methoden.html">Vergleich der Interpolationsmethoden</a>.</p>
<p><img src="nwfva.png" height = "400" width="600" alt="Plots of height vs age"></p>
<p><a href="https://cran.r-project.org/package=mmodely">mmodely</a> v0.2.2: Provides functions to perform multivariate modeling of evolved traits, with special attention to understanding the interplay of the multi-factorial determinants of their origins in complex ecological settings. See <a href="https://www.cell.com/trends/ecology-evolution/fulltext/S0169-5347(06)00400-9?_returnURL=https%3A%2F%2Flinkinghub.elsevier.com%2Fretrieve%2Fpii%2FS0169534706004009%3Fshowall%3Dtrue">Stephens (2007)</a>, <a href="https://onlinelibrary.wiley.com/doi/10.1111/j.1420-9101.2010.02210.x">Gruebner (2011)</a>, and <a href="https://link.springer.com/article/10.1007/s00265-010-1028-7">Garamszegi (2011)</a> for background, and the examples on <a href="https://cran.r-project.org/web/packages/mmodely/vignettes/Schruth-mmodely-vignette-Vision.pdf">primate vision</a> and <a href="https://cran.r-project.org/web/packages/mmodely/vignettes/Schruth-mmodely-vignette-Vocal.pdf">vocal communications</a>.</p>
<p><a href="https://cran.r-project.org/package=webSDM">webSDM</a> v1.1-1: Implements the method of <a href="https://www.authorea.com/users/522841/articles/595095-integrating-food-webs-in-species-distribution-models-improves-ecological-niche-estimation-and-predictions?commit=5fe6a87efdbbb3461a2b7301435ec1bfb2397cf3">Poggiato et al. (2022)</a> for working with tropic Species Distribution Models. There is an <a href="https://cran.r-project.org/web/packages/webSDM/vignettes/Introduction.html">Introduction</a> and there are vignettes on <a href="Composite variables and biotic-abiotic interactions">Composit variables</a>, <a href="https://cran.r-project.org/web/packages/webSDM/vignettes/Differences_with_SDMs.html">Differences between SDM and Trophic SDM</a>.</p>
<p><img src="webSDM.png" height = "450" width="450" alt="Plots of species distributions"></p>
<h3 id="epidemiology">Epidemiology</h3>
<p><a href="https://cran.r-project.org/package=exDE">exDE</a> v1.0.0: Provides tools to set up modular ordinary and delay differential equation models for mosquito-borne pathogens, focusing on malaria. See <a href="https://www.medrxiv.org/content/10.1101/2022.11.07.22282044v1">Wu et al. (2022)</a> for a description on the methods implemented. There are ten vignettes including <a href="https://cran.r-project.org/web/packages/exDE/index.html">Basic Copmetition Aquatic Mosquito Model</a> and <a href="https://cran.r-project.org/web/packages/exDE/vignettes/human_sip.html">SIP Human Model</a>.</p>
<p><img src="exDE.png" height = "400" width="400" alt="Plots of results for 3 population human model"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=idopNetwork">idopNetwork</a> v0.1.1: Implements a cartographic tool to chart spatial microbial interaction networks. See <a href="https://academic.oup.com/genetics/article/180/2/821/6073848?login=false">Kim et al. (2008)</a> and <a href="https://academic.oup.com/bib/article/13/2/162/253162?login=false">Wang et al. (2011)</a> for information on functional clustering, <a href="https://www.nature.com/articles/s41540-019-0116-1">Chen et al. (2019)</a> and <a href="https://www.tandfonline.com/doi/full/10.1080/19490976.2022.2106103">Cao et al. (2022)</a> for background on the model, and the <a href="https://cran.r-project.org/web/packages/idopNetwork/vignettes/idopNetwork_vignette.html">vignette</a> for examples.</p>
<p><img src="idop.png" height = "400" width="600" alt="Plots of Niche index vs. habitat index for various bacteria"></p>
<p><a href="https://cran.r-project.org/package=tip">tip</a> v0.1.0: Provides functions to cluster data without specifying the number of clusters using the Table Invitation Prior (TIP) introduced by <a href="https://www.mdpi.com/2073-4425/13/11/2036">Harrison et al. (2022)</a>. There are vignettes on matrix clustering with <a href="https://cran.r-project.org/web/packages/tip/vignettes/matrix-CONSTANT-simulated-vignette.html">CONSTANT</a> and <a href="https://cran.r-project.org/web/packages/tip/vignettes/matrix-MNIW-simulated-vignette.html">MNIW</a>, <a href="https://cran.r-project.org/web/packages/tip/vignettes/tensor-CONSTANT-simulated-vignette.html">Tensor clustering CONSTANT</a>, <a href="https://cran.r-project.org/web/packages/tip/vignettes/vector-NIW-iris-vignette.html">iris NIW</a>, and <a href="https://cran.r-project.org/web/packages/tip/vignettes/vector-NIW-usarrests-vignette.html">usarrests NIW</a>.</p>
<p><img src="tip.png" height = "500" width="400" alt="Posterior similarity matrix for clusters"></p>
<p><a href="https://CRAN.R-project.org/package=scistreer">scistreer</a> v1.0.1: Enables fast maximum-likelihood phylogeny inference from noisy single-cell data using the <em>ScisTree</em> algorithm described in <a href="https://academic.oup.com/bioinformatics/article/36/3/742/5555811?login=false">Wu (2019)</a> making the method applicable to massive single-cell datasets (>10,000 cells). Look <a href="https://kharchenkolab.github.io/scistreer/">here</a> for an example.</p>
<p><img src="scistreer.png" height = "500" width="500" alt="Visualization of maximum likelihood tree"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=tidyclust">tidyclust</a> v0.1.1: Implements a common interface to specifying clustering models, in the same style as <code>parsnip</code>. Creates unified interface across different functions and computational engines. See <a href="https://cran.r-project.org/web/packages/tidyclust/readme/README.html">README</a> for examples.</p>
<p><img src="tidyclust.svg" height = "400" width="600" alt="Examples of k means vs. hierarchical clusters"></p>
<p><a href="https://cran.r-project.org/package=VSOLassoBag">VSOLassoBag</a> v0.99.0: Implements an integrated <em>Wrapped LASSO</em> ensemble learning strategy to help select efficient, stable, and high confidential variables from omics-based data. Functions integrate and vote on variables generated from multiple LASSO models to determine the optimal candidates. See <a href="https://www.science.org/doi/10.1126/scitranslmed.aax7533">Luo et al. (2020)</a> for details and the <a href="https://cran.r-project.org/web/packages/VSOLassoBag/vignettes/VSOLassoBag.html">vignette</a> for examples.</p>
<p><img src="VSO.png" height = "400" width="400" alt="Histogram of observed frequency distribution"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=tensorFun">tensorFun</a> v0.1.1: Provides basic functions to handle higher-order tensor data. See <a href="https://epubs.siam.org/doi/10.1137/07070111X">Kolda and Bader (2009)</a> for background on tensor decompositions, <a href="https://arxiv.org/abs/1910.06677">Bau and Ng (2021)</a> for information on missing values, and the <a href="https://cran.r-project.org/web/packages/tensorFun/vignettes/A-short-introduction-to-tensorFun.html">vignette</a> for a short introduction.</p>
<p><a href="https://cran.r-project.org/package=TransTGGM">TransTGGM</a> V1.0.0: Implements a transfer learning framework for tensor Gaussian graphical models, which takes full advantage of informative auxiliary domains even when non-informative auxiliary domains are present. See <a href="https://arxiv.org/abs/2211.09391">Ren, Zhen, and Wang</a> for background and the <a href="https://cran.r-project.org/web/packages/TransTGGM/vignettes/TransTGGM.html">vignette</a>.</p>
<h3 id="networks">Networks</h3>
<p><a href="https://cran.r-project.org/package=nett">nett</a> 1.0.0: Provides multiple methods for fitting, model selection and goodness-of-fit testing in degree-corrected stochastic blocks models. Implements the methods in <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-41/issue-4/Pseudo-likelihood-methods-for-community-detection-in-large-sparse-networks/10.1214/13-AOS1138.full">Amini et al.(2013)</a>, <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12117">Bickel and Sarkar (2015)</a>, <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-44/issue-1/A-goodness-of-fit-test-for-stochastic-block-models/10.1214/15-AOS1370.full">Lei (2016)</a>, <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-45/issue-2/Likelihood-based-model-selection-for-stochastic-block-models/10.1214/16-AOS1457.full">Wang and Bickel (2017)</a> and more. There are vignettes <a href="https://cran.r-project.org/web/packages/nett/vignettes/Community_Detection.html">Community Detection</a>, <a href="https://cran.r-project.org/web/packages/nett/vignettes/Visualization.html">Visualization</a>, <a href="https://cran.r-project.org/web/packages/nett/vignettes/explore-comm.html">Explore Comm</a>, and <a href="https://cran.r-project.org/web/packages/nett/vignettes/hard_dcsbm_testing.html">dcsbm testing</a>.</p>
<p><img src="nett.png" height = "400" width="600" alt="Network visualization"></p>
<h3 id="pharma">Pharma</h3>
<p><a href="https://cran.r-project.org/package=DrugSim2DR">DrugSim2DR</a> v0.1.0: Implements a tool to predict drug functional similarity for drug repurposing. See the <a href="https://cran.r-project.org/web/packages/DrugSim2DR/vignettes/DrugSim2DR.html">vignette</a>.</p>
<p><img src="Drug.png" height = "400" width="600" alt="Heatmaps of targets for Phenelzine"></p>
<p><a href="https://cran.r-project.org/package=parttime">parttime</a> v0.1.0: Provides classes for embedding partial missingness as a central part of datetime classes allowing for more ergonomic use of datetimes for challenging datetime computation, including calculations of overlapping date ranges, imputations, and more. See <a href="https://cran.r-project.org/web/packages/parttime/readme/README.html">README</a> for examples.</p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=GAGAs">GAGAs</a> v0.5.1: Implements the Global Adaptive Generative Adjustment Algorithm for generalized liner models used for improving the computational efficiency in the high-dimensional data analysis. See <a href="https://arxiv.org/abs/1911.00658">Wang et al. (2022)</a> for the theory.</p>
<p><a href="https://cran.r-project.org/package=kfino">kfino</a> v1.0.0: Implements method for detecting outliers with a Kalman filter on impulsed noised outliers and prediction on cleaned data. See <a href="https://arxiv.org/abs/2208.00961">Cloez et al. (2022)</a> for the details and the vignettes on <a href="https://cran.r-project.org/web/packages/kfino/vignettes/HowTo.html">outlier detection</a> and <a href="https://cran.r-project.org/web/packages/kfino/vignettes/multipleFit.html">outlier detection with parallelization</a>.</p>
<p><img src="kfino.png" height = "400" width="600" alt="Scatter plot with predicted outliers"></p>
<p><a href="https://cran.r-project.org/package=pwrss">pwrss</a> v0.2.0: Implements power and sample size calculations for a number of one, two and three sample tests. See the <a href="https://cran.r-project.org/web/packages/pwrss/vignettes/examples.html">vignette</a> for examples.</p>
<p><img src="pwrss.png" height = "400" width="600" alt="Densities illustrating power calculations for various tests"></p>
<p><a href="https://CRAN.R-project.org/package=spatstat.model">spatstat.models</a> v3.0-2: A member of the <a href="https://spatstat.r-universe.dev/ui#builds"><code>spatstat</code></a> family of packages, it provides multiple functions for exploratory data analysis and nonparametric analysis of spatial data, mainly spatial point patterns. See <a href="https://spatstat.org/">spatstat.org</a> for documentation.</p>
<p><a href="https://cran.r-project.org/package=vMF">vMF</a> v0.0.1: Provides functions for fast sampling from von Mises-Fisher distribution using the method proposed in <a href="https://www.tandfonline.com/doi/abs/10.1080/03610919408813161">Wood (1994)</a>. See the <a href="https://cran.r-project.org/web/packages/vMF/vignettes/vMF.pdf">vignette</a>.</p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=ardl.nardl">ardl.nardl</a> v1.2.2: Implements linear and nonlinear autoregressive distributed lag (ARDL & NARDL) models and the corresponding error correction models and includes a test for long-run and short-run asymmetry and the <a href="https://onlinelibrary.wiley.com/doi/10.1002/jae.616">Pesaran, Shin & Smith (2001)</a> bounds test for level relationships.</p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=cookies">cookies</a> v0.2.0: Provides tools for working with cookies in <code>shiny</code> apps, in part by wrapping the <a href="https://github.com/js-cookie/js-cookie"><code>js-cookie</code></a> JavaScript library. See <a href="https://cran.r-project.org/web/packages/cookies/readme/README.html">README</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=formatdown">formatdown</a> v0.1.1: Provides a small set of tools for formatting tasks when creating documents in <code>rmarkdown</code> or <code>quarto</code>. See the <a href="https://cran.r-project.org/web/packages/formatdown/vignettes/format_powers_of_ten.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=hellorust">hellorust</a> v1.0.0: Implements tools to use Rust code in R without hacks or frameworks. Includes basic examples of importing cargo dependencies, spawning threads and passing numbers or strings from Rust to R. Look <a href="https://jeroen.github.io/erum2018/#1">here</a> and <a href="https://github.com/r-rust/hellorust">here</a> for for documentation.</p>
<p><a href="https://cran.r-project.org/package=prismjs">prismjs</a> v1.1.0: Implements a server-side rendering in R using <a href="https://prismjs.com/">Prism</a>, a lightweight, extensible syntax highlighter, built with modern web standards in mind such that no JavaScript library is required in the resulting HTML documents. Look <a href="https://docs.ropensci.org/prismjs/">here</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=rjtools">rjtools</a> v1.0.9: Provides tools to create an <a href="https://journal.r-project.org/">R Journal</a> <code>rmarkdown</code> template article, that will generate HTML and PDF versions of your paper. There are vignettes <a href="https://cran.r-project.org/web/packages/rjtools/vignettes/article_template.html">rjtools-template</a>, <a href="https://cran.r-project.org/web/packages/rjtools/vignettes/check_functions.html">Check</a>, <a href="https://cran.r-project.org/web/packages/rjtools/vignettes/create_article.html">Create article</a>, and <a href="https://cran.r-project.org/web/packages/rjtools/vignettes/format-details.html">Format details</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=funkyheatmap">funkyheatmap</a> v0.1.0: Provides functions for generating heatmap-like visualizations for benchmark data frames, which can be fine-tuned with annotations for columns and rows. See <a href="https://www.nature.com/articles/s41587-019-0071-9">Saelens et al. (2019)</a> for background and the vignettes <a href="https://cran.r-project.org/web/packages/funkyheatmap/vignettes/dynbenchmark.html">Recreating the dynbenchmark figures</a> and <a href="https://cran.r-project.org/web/packages/funkyheatmap/vignettes/mtcars.html">Demo with mtcars</a> for examples.</p>
<p><img src="funky.png" height = "700" width="600" alt="Heat map with annotations"></p>
<p><a href="https://cran.r-project.org/package=ggbrain">ggbrain</a> v0.8.0: Implements a <code>ggplot2</code>-consistent approach to generating 2D displays of volumetric brain imaging data from multiple NIfTI images. There is an <a href="https://cran.r-project.org/web/packages/ggbrain/vignettes/ggbrain_introduction.html">Introduction</a> and there are vignettes on <a href="https://cran.r-project.org/web/packages/ggbrain/vignettes/ggbrain_aesthetics.html">Aesthetic refinement</a> and <a href="https://cran.r-project.org/web/packages/ggbrain/vignettes/ggbrain_labels.html">Annotations and labels</a>.</p>
<p><img src="ggbrain.png" height = "700" width="600" alt="Three views of a brain"></p>
<p><a href="https://cran.r-project.org/package=ggpcp">ggpcp</a> v0.2.0: Provides a Grammar of Graphics implementation of parallel coordinate plots that incorporates categorical variables into the plots in a principled manner. Look <a href="https://github.com/heike/ggpcp">here</a> for examples.</p>
<p><img src="ggpcp.png" height = "400" width="600" alt="Parallel plot with labels"></p>
<p><a href="https://cran.r-project.org/package=ggredist">ggredist</a> v0.0.2: Provides <code>ggplot2</code> extensions for political map making based on simple features and includes palettes and scales for red to blue color mapping and for discrete maps. See <a href="https://cran.r-project.org/web/packages/ggredist/readme/README.html">README</a> for an example.</p>
<p><img src="ggredist.png" height = "400" width="600" alt="Vote share map of Oregon"></p>
<p><a href="https://cran.r-project.org/package=ggsector">ggsector</a> v1.6.6: Implements functions that use <code>grid</code> and <code>ggplot2</code> to plot sectors, draw complex heat maps and interact with <code>Seurat</code> to plot gene expression percentages. See the <a href="https://cran.r-project.org/web/packages/ggsector/vignettes/ggsector.html">vignette</a>.</p>
<p><img src="ggsector.png" height = "400" width="600" alt="Heat map with sectors"></p>
<p><a href="https://cran.r-project.org/package=sherlock">sherlock</a> v0.5.1: Provides graphical displays and statistical tools for structured problem solving and diagnosis with functions that are especially useful for applying the process of elimination as a problem diagnosis technique. See <a href="https://dokumen.pub/the-new-science-of-fixing-things-powerful-insights-about-root-cause-analysis-that-will-transform-product-and-process-performance-9798626423686.html">Hartsborne (2020)</a> for background and <a href="https://cran.r-project.org/web/packages/sherlock/readme/README.html">README</a> for examples.</p>
<p><img src="sherlock.png" height = "400" width="600" alt="Example of a Polar Small Multiples Plot"></p>
<script>window.location.href='https://rviews.rstudio.com/2023/01/03/november-2022-top-40-new-cran-packages/';</script>
October 2022: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2022/11/28/october-2022-top-40-new-cran-packages/
Mon, 28 Nov 2022 00:00:00 +0000https://rviews.rstudio.com/2022/11/28/october-2022-top-40-new-cran-packages/
<p>One hundred seventy-four new packages made it to CRAN in October. Here are my “Top 40” selections in sixteen categories: Astronomy, Biology, Business, Computational Methods, Data, Ecology, Finance, Genomics, Mathematics, Machine Learning, Medicine, Pharma, Statistics, Time Series, Utilities, Visualization.</p>
<h3 id="astronomy">Astronomy</h3>
<p><a href="https://cran.r-project.org/package=skylight">skylight</a> v1.1: Provides a function to calculate sky illuminance values (in lux) for both the sun and moon. The model is a verbatim translation of the code by <a href="https://archive.org/details/DTIC_ADA182110/page/n15/mode/2up">Janiczek and DeYoung (1987)</a>. There are vignettes for <a href="https://cran.r-project.org/web/packages/skylight/vignettes/skylight.html">Use</a> and <a href="https://cran.r-project.org/web/packages/skylight/vignettes/skylight_advanced.html">Advanced Use</a>.</p>
<h3 id="biology">Biology</h3>
<p><a href="https://cran.r-project.org/package=palaeoverse">palaeoverse</a> v1.0.0:
Provides tools to support data preparation and exploration for palaeobiological analyses including functions for data cleaning, binning (time and space), summarisation and visualisation with the goals of improving code reproducibility and accessibility and establishing standards for the palaeobiological community. See <a href="https://eartharxiv.org/repository/view/4619/">Jones et al.</a> for details, and the <a href="https://cran.r-project.org/web/packages/palaeoverse/vignettes/structure-and-standards.html">contribution guide</a> to get involved.</p>
<p><a href="https://cran.r-project.org/package=pirouette">pirouette</a> v1.6.5: Implements a method to create a Bayesian posterior from a phylogeny that depicts the true evolutionary relationships. See <a href="https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.13514">Richèl et al. (2020)</a> for background. There are several vignettes including a <a href="https://cran.r-project.org/web/packages/pirouette/vignettes/tutorial.html">Tutorial</a>, a <a href="https://cran.r-project.org/web/packages/pirouette/vignettes/demo.html">demo</a>, and a guide showing how to use the package in a scientific <a href="https://cran.r-project.org/web/packages/pirouette/vignettes/experiment.html">experiment</a>.</p>
<p><img src="pirouette.png" height = "400" width="400" alt="Heat map depicting DAN alignment"></p>
<h3 id="business">Business</h3>
<p><a href="https://cran.r-project.org/package=bupaverse">bupaverse</a> v0.1.0: Facilitates loading the packages comprising the <a href="https://bupar.net/">bupaverse</a>, an integrated suite of R packages for handling and analysing business process data, developed by the Business Informatics research group at Hasselt University, Belgium. See the <a href="https://cran.r-project.org/web/packages/bupaverse/vignettes/getting_started.html">Getting Started Guide</a>.</p>
<p><img src="bupaverse.png" height = "300" width="500" alt="bupaR logo"></p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=fastWavelets">fastWavelets</a> v1.0.1: Provides an <code>Rcpp</code> implementation of the Maximal Overlap Discrete Wavelet Transform (MODWT) and the À Trous Discrete Wavelet Transform. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0022169418303317?via%3Dihub">Quilty & Adamowski (2018)</a> for background and <a href="https://cran.r-project.org/web/packages/fastWavelets/readme/README.html">README</a> for examples.</p>
<p><img src="fastWavelets.png" height = "300" width="500" alt="Plots of wavelet coefficients"></p>
<p><a href="https://cran.r-project.org/package=gips">gips</a> v1.0.0: Employs the methods described in <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-50/issue-3/Model-selection-in-the-space-of-Gaussian-models-invariant-by/10.1214/22-AOS2174.short">Graczyk et al. (2022)</a> to find the permutation symmetry group under which the covariance matrix of the data is invariant. See the vignettes <a href="https://cran.r-project.org/web/packages/gips/vignettes/Optimizers.html">Optimizers</a>, <a href="https://cran.r-project.org/web/packages/gips/vignettes/Theory.html">Theory</a>, and <a href="https://cran.r-project.org/web/packages/gips/vignettes/gips.html">gips</a>.</p>
<p><a href="https://cran.r-project.org/package=HomomorphicEncryption">HomomorphicEncryption</a> v0.1.0: Implements the <a href="https://eprint.iacr.org/2012/144">Brakerski-Fan-Vercauteren (2012)</a>, <a href="https://dl.acm.org/doi/10.1145/2633600">Brakerski-Gentry-Vaikuntanathan (2014)</a>, and <a href="https://eprint.iacr.org/2016/421.pdf">Cheon-Kim-Kim-Song (2016)</a> schema for fully homomorphic encryption. There are seven short vignettes including <a href="https://cran.r-project.org/web/packages/HomomorphicEncryption/vignettes/BFV.html">BFV</a>, <a href="https://cran.r-project.org/web/packages/HomomorphicEncryption/vignettes/BGV.html">BGV</a>, and <a href="https://cran.r-project.org/web/packages/HomomorphicEncryption/vignettes/CKKS.html">CKKS</a>.</p>
<p><a href="https://cran.r-project.org/package=rxode2random">rxode2random</a> v2.0.9: Implements parallel random number generation. <a href="https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12052">See Wang et al. (2016)</a> and <a href="https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12445">Fidler et al (2019)</a> for background and <a href="https://ascpt.onlinelibrary.wiley.com/doi/10.1002/psp4.12445">README</a> for an example..</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=airnow">airnow</a> v0.1.0: Provides functions to retrieve U.S. Government <a href="https://www.airnow.gov/">AirNow</a> air quality data. See <a href="https://cran.r-project.org/web/packages/airnow/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=amazonadsR">amazonadsR</a> v0.1.0: Provides functions to collect data on digital marketing campaigns using the <a href="https://windsor.ai/api-fields/">Windsor.ai API</a>. See the <a href="https://cran.r-project.org/web/packages/amazonadsR/vignettes/tutorial.html">tutorial</a> for an example and also look at the related new packages:
<a href="https://cran.r-project.org/package=bingadsR"><code>bingadsR</code></a>,
<a href="https://cran.r-project.org/package=facebookadsR"><code>facebookadsR</code></a>,
<a href="https://cran.r-project.org/package=googleadsR"><code>googleadsR</code></a>,
<a href="https://cran.r-project.org/package=instagramadsR"><code>instagramadsR</code></a>,
<a href="https://cran.r-project.org/package=linkedInadsR"><code>linkedinadsR</code></a>,
<a href="https://cran.r-project.org/package=pinterestadsR"><code>pinterestadsR</code></a>,
<a href="https://cran.r-project.org/package=redditadsR"><code>redditadsR</code></a>,
<a href="https://cran.r-project.org/package=snapchatadsR"><code>snapchatadsR</code></a>,
<a href="https://cran.r-project.org/package=tiktokadsR"><code>ticktokadsR</code></a>,
<a href="https://cran.r-project.org/package=twitteradsR"><code>twitteradsR</code></a>. Pablo Sanchez was on a roll in October.</p>
<p><img src="amazon.png" height = "400" width="300" alt="Distribution of clicks for two ads campaigns"></p>
<p><a href="https://cran.r-project.org/package=congress">congress</a> v0.0.1: Provides functions to download and read data on United States congressional proceedings through the <a href="https://github.com/LibraryOfCongress/api.congress.gov/">Congress.gov</a> API of the Library of Congress. See <a href="https://cran.r-project.org/web/packages/congress/readme/README.html">README</a> for an example.</p>
<h3 id="ecology">Ecology</h3>
<p><a href="https://cran.r-project.org/package=canaper">canaper</a> v1.0.0: Provides functions to analyze the spatial distribution of biodiversity especially useful in the categorical analysis of neo- and paleo-endemism (CANAPE) as described in <a href="https://www.nature.com/articles/ncomms5473">Mishler et al. (2014)</a> and for statistical tests to determine the types of endemism that occur in a study area while accounting for the evolutionary relationships of species. There are vignettes on <a href="https://cran.r-project.org/web/packages/canaper/vignettes/canape.html">CANAPE</a>, <a href="https://cran.r-project.org/web/packages/canaper/vignettes/how-many-rand.html">randomization</a>, and <a href="https://cran.r-project.org/web/packages/canaper/vignettes/parallel.html">parallel computing</a>.</p>
<p><img src="canaper.png" height = "300" width="500" alt="Plots showing phylogenetic diversity and endemism"></p>
<p><a href="https://cran.r-project.org/package=EcoEnsemble">EcoEnsemble</a> v1.0.1: Provides functions to fit and sample from the ensemble model described in <a href="https://onlinelibrary.wiley.com/doi/abs/10.1111/faf.12310">Spence et al (2018)</a>. There is an <a href="https://cran.r-project.org/web/packages/EcoEnsemble/vignettes/EcoEnsemble.html">Introduction</a> and there are two additional vignettes: <a href="https://cran.r-project.org/web/packages/EcoEnsemble/vignettes/ExploringPriors.html">ExploringPriors</a> and <a href="https://cran.r-project.org/web/packages/EcoEnsemble/vignettes/SyntheticData.html">SyntheticData</a>.</p>
<p><img src="EcoEnsemble.png" height = "500" width="500" alt="Multiple plots of ensemble object"></p>
<p><a href="https://cran.r-project.org/package=rTRIPLEXCWFlux">rTRIPLEXCWFlux</a> v0.2.0: Encodes the carbon uptake submodule and evapotranspiration submodule of the TRIPLEX-CW-Flux model to run the simulation of carbon-water coupling. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S030438000800361X?via%3Dihub">Zhou et al. (2008)</a> <a href="https://www.semanticscholar.org/paper/Evaporation-and-environment.-Monteith/428f880c29b7af69e305a2bf73e425dfb9d14ec8">Monteith (1965)</a> for background and the <a href="https://cran.r-project.org/web/packages/rTRIPLEXCWFlux/vignettes/model-vignette.html">vignette</a> for examples.</p>
<p><img src="rTRIP.png" height = "500" width="500" alt="Plots showing simulated evapotranspiration (ET) by season"></p>
<p><a href="https://cran.r-project.org/package=stopdetection">stopdetection</a> v0.1.1: Enables <em>stop</em> detection in time stamped trajectory by implementing the Stay Point detection algorithm originally described in <a href="https://ieeexplore.ieee.org/document/5088915">Ye (2009)</a> that uses time and distance thresholds to characterize spatial regions as <em>stops</em>. See the <a href="https://cran.r-project.org/web/packages/stopdetection/vignettes/stopdetection-vignette.html">vignette</a> for examples.</p>
<p><img src="stop.png" height = "500" width="500" alt="Latitude vs. longitude plot showing distance in meters subject may range from a stop point"></p>
<h3 id="finance">Finance</h3>
<p><a href="https://cran.r-project.org/package=highOrderPortfolios">highOrderPortfolios</a> v0.1.0: Implements methods to select portfolios using high order moments to characterize return distributions. See <a href="https://arxiv.org/abs/2008.00863">Zhou & Palomar (2021)</a> and <a href="https://arxiv.org/abs/2206.02412">Wang et al. (2022)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/highOrderPortfolios/vignettes/DesignOfHighOrderPortfolios.html">vignette</a> to get started.</p>
<p><img src="highorder.png" height = "500" width="500" alt="Plot of portfolio weights vs. asset indexes for two methods"></p>
<p><a href="https://cran.r-project.org/package=MSTest">MSTest</a> v0.1.0: Implements hypothesis testing procedures described in <a href="https://onlinelibrary.wiley.com/doi/10.1002/jae.3950070506">Hansen (1992)</a>, <a href="https://onlinelibrary.wiley.com/doi/abs/10.3982/ECTA8609">Carrasco, Hu, & Ploberger (2014)</a> and <a href="https://www.tandfonline.com/doi/full/10.1080/07474938.2017.1307548">Dufour & Luger (2017)</a> that can be used to identify the number of regimes in Markov switching models.
See <a href="https://cran.r-project.org/web/packages/MSTest/readme/README.html">README</a> for an example.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=metevalue">metevalue</a> v0.1.13: Implements the <a href="https://projecteuclid.org/journals/annals-of-statistics/volume-49/issue-3/E-values-Calibration-combination-and-applications/10.1214/20-AOS2020.full">e-value</a> method to correct p-values in omics data association studies. See <a href="https://bioconductor.org/packages/release/bioc/html/BiSeq.html">Hebestreit & Klein (2022)</a> and <a href="https://bioconductor.org/packages/release/bioc/html/methylKit.html">Akalin et.al (2012)</a> for background and the <a href="https://cran.r-project.org/web/packages/metevalue/vignettes/metevalue.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=SCpubr">SCpubr</a> v1.0.4: Implements a system that provides a streamlined way of generating publication ready plots for known Single-Cell transcriptomics data. Look <a href="https://enblacar.github.io/SCpubr-book/">here</a> for an online reference manual.</p>
<p><img src="SCpubr.png" height = "500" width="500" alt="Groupwise DE analysis plot"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=Boov">Boov</a> v1.0.0: Provides functions to perform the Boolean operations union, difference and intersection on volumes. Computations are done by the <code>C++</code> library <a href="https://www.cgal.org/"><code>CGAL</code></a>. See <a href="https://cran.r-project.org/web/packages/Boov/readme/README.html">README</a> for some examples. Also, have a look at the package <a href="https://cran.r-project.org/package=MinkowskiSum">MinkowskiSum</a>.</p>
<p><img src="Boov.gif" height = "400" width="400" alt="Difference of two three dimensional objects"></p>
<p><a href="https://cran.r-project.org/package=fitode">fitode</a> v0.1.1: Provides methods and functions for fitting ordinary differential equations that use sensitivity equations to compute gradients of ODE trajectories with respect to underlying parameters. See the <a href="https://cran.r-project.org/web/packages/fitode/vignettes/fitode.pdf">vignette</a> for details.</p>
<p><a href="https://cran.r-project.org/package=manifold">manifold</a> v0.1.1: Implements operations for Riemannian manifolds including geodesic distance, Riemannian metric, and exponential and logarithm maps, and also incorporates a random object generator on the manifolds. See <a href="https://onlinelibrary.wiley.com/doi/10.1111/biom.13385">Dai, Lin, and Müller (2021)</a> for details.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=SoftBart">SoftBart</a> v1.0.1: Implements the SoftBart model of described by <a href="https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12293">Linero and Yang (2018)</a> with the optional use of a sparsity-inducing prior to allow for variable selection. The <a href="https://cran.r-project.org/web/packages/SoftBart/vignettes/SoftBart-Vig.pdf">vignette</a> contains theory and examples.</p>
<p><img src="regtree.png" height = "500" width="600" alt="Plots showing the difference between hard and soft regression trees"></p>
<p><a href="https://cran.r-project.org/package=tidyfit">tidyfit</a> v0.5.1: Extends the tidy data environment with functions to fit and cross validate linear regression and classification algorithms on grouped data. There are several vignettes including <a href="https://cran.r-project.org/web/packages/tidyfit/vignettes/Predicting_Boston_House_Prices.html">Predicting Boston House Prices</a>, <a href="https://cran.r-project.org/web/packages/tidyfit/vignettes/Multinomial_Classification.html">Multinomial Classification</a>, and <a href="https://cran.r-project.org/web/packages/tidyfit/vignettes/Rolling_Window_Time_Series_Regression.html">Rolling Window Time Series Regression</a>.</p>
<p><img src="tidyfit.jpeg" height = "700" width="500" alt="Flowchart of the model fitting methodology"></p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=cities">cities</a> v0.1.0: Provides functions to simulate clinical trials and summarize causal effects and treatment policy estimands in the presence of intercurrent events. Have a look at the <a href="https://cran.r-project.org/web/packages/cities/vignettes/CITIES_demo.html">demo</a>.</p>
<p><img src="cities.png" height = "400" width="400" alt="Plots showing proportion of treatment discontinuities by trial arm at various times"></p>
<p><a href="https://cran.r-project.org/package=RCT2">RCT2</a> v0.0.1: Implements various statistical methods for designing and analyzing two-stage randomized controlled trials using the methods developed by <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.2020.1775612?journalCode=uasa20">Imai, Jiang, and Malani (2021)</a> and <a href="https://arxiv.org/abs/2011.07677">Imai, Jiang, and Malani (2022)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/RCT2/vignettes/interference_vignette.html">Interference</a> and <a href="https://cran.r-project.org/web/packages/RCT2/vignettes/spillover_vignette.html">Causal Inference</a>.</p>
<h3 id="pharma">Pharma</h3>
<p><a href="https://cran.r-project.org/package=DTSEA">DTSEA</a> v0.0.3: Implements a novel tool to identify candidate drugs against a particular disease based on the drug target set enrichment analysis. It assumes the most effective drugs are those with a closer affinity in the protein-protein interaction network to the specified disease. See <a href="https://www.sciencedirect.com/science/article/pii/S0013935122002171?via%3Dihub">Gómez-Carballa et al. (2022)</a> and <a href="https://www.medsci.org/v19p0402.htm">Feng et al. (2022)</a> for disease expression profiles, <a href="https://academic.oup.com/nar/article/46/D1/D1074/4602867">Wishart et al. (2018)</a> and <a href="https://academic.oup.com/nar/article/45/D1/D945/2605707?login=false">Gaulton et al. (2017)</a> for drug target information, and <a href="https://academic.oup.com/nar/article/49/D1/D545/5943834?login=false">Kanehisa et al. (2021)</a> for the details of KEGG database. There is a <a href="https://cran.r-project.org/web/packages/DTSEA/vignettes/DTSEA.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=nlmixr2lib">nlmixr2lib</a> v0.1.0: Provides tools to create model libraries for <code>nlmixr2</code>. Models include pharmacokinetic, pharmacodynamic, and disease models used in pharmacometrics. See the vignette <a href="https://cran.r-project.org/web/packages/nlmixr2lib/vignettes/create-model-library.html">Creating a model library</a>.</p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=aIc">aIc</a> v1.0: Implements set of tests for compositional pathologies including for coherence of correlations as suggested by <a href="https://www.sciencedirect.com/science/article/pii/S2590197420300082?via%3Dihub">Erb et al. (2020)</a>, compositional dominance of distance, compositional perturbation invariance as suggested by <a href="https://link.springer.com/article/10.1007/BF00891269">(Aitchison (1992)</a> and singularity of the covariation matrix. See the <a href="https://cran.r-project.org/web/packages/aIc/vignettes/aIc_vignette.html">vignette</a> for details and examples.</p>
<p><img src="aIc.png" height = "300" width="500" alt="Proportion of dominant distance densities"></p>
<p><a href="https://cran.r-project.org/package=ktweedie">ktweedie</a> v1.0.1: Uses Reproducing Kernel Hilbert Space methods to implement Tweedie compound Poisson gamma models with high-dimensional predictors for the analyses of zero-inflated response variables. See the <a href="https://cran.r-project.org/web/packages/ktweedie/vignettes/ktweedie-vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=missoNet">missoNet</a> v1.0.0: Implements efficient procedures for fitting conditional graphical lasso models linking predictor variables to response variables or tasks, when the response data may contain missing values. See the <a href="https://cran.r-project.org/web/packages/missoNet/vignettes/missoNet.html">vignette</a> for examples.</p>
<p><img src="missoNet.png" height = "500" width="500" alt="Multiple correlation plots for various network fits"></p>
<p><a href="https://cran.r-project.org/package=ShapleyOutlier">ShalpeyOutlier</a> v0.1.0: Provides methods to use <a href="https://www.investopedia.com/terms/s/shapley-value.asp#:~:text=Essentially%2C%20the%20Shapley%20value%20is,or%20less%20than%20the%20others.">Shapley values</a> to detect, explain, and cell wise impute multivariate outliers. See <a href="https://arxiv.org/abs/2210.10063">Mayrhofer and Filzmoser (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/ShapleyOutlier/vignettes/ShapleyOutlier_examples.html">vignette</a> for examples.</p>
<p><img src="Shapley.png" height = "500" width="500" alt="Explanation of Mahalanobis distance for six observations"></p>
<p><a href="https://cran.r-project.org/package=SpatialfdaR">SpatialfdaR</a> v1.0.0: Provides functions to that implement finite element analysis methods to spatial functional data analysis. See <a href="https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/rssb.12009">Sangalli et al. (2013)</a> and <a href="https://www.sciencedirect.com/science/article/pii/S0047259X17302944?via%3Dihub">Bernardi et al. (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/SpatialfdaR/vignettes/Meuse.html">vignette</a> for an example.</p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=dfms">dfms</a> v0..1.3: Provides a user friendly and computationally efficient approach to estimate linear Gaussian dynamic factor models using Kalman filter and EM algorithm methods. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S030440761100039X?via%3Dihub">Doz et al. (2011)</a> and <a href="https://onlinelibrary.wiley.com/doi/10.1002/jae.2306">Banbura & Modugno (2014)</a> for background and the <a href="https://cran.r-project.org/web/packages/dfms/vignettes/introduction.html">vignette</a> for examples.</p>
<p><img src="dfms.png" height = "500" width="500" alt="Euro time series models"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=ExclusionTable">ExclusionTable</a> v1.0.0: Provides functions for creating tables of excluded observations by reporting the number before and after each <code>subset()</code> call together with the number of observations that have been excluded. See the <a href="https://cran.r-project.org/web/packages/ExclusionTable/vignettes/ExclusionTable_vignette.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=shiny.tailwind">shiny.tailwind</a> v0.2.2: Allows <a href="https://tailwindcss.com/">TailwindCSS</a> to be used in Shiny apps with just-in-time compiling including custom <code>CSS</code> with <code>@apply</code> directive, and custom tailwind configurations. See <a href="https://cran.r-project.org/web/packages/shiny.tailwind/readme/README.html">README</a> for examples.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=AlphaHull3D">AlphaHull3D</a> v1.1.0: Provides functions to compute the <a href="https://en.wikipedia.org/wiki/Alpha_shape">alpha hull</a> of a set of points (informallly: the shape formed by these points) in 3D space. See <a href="https://cran.r-project.org/web/packages/AlphaHull3D/readme/README.html">README</a> for some visualizations, and also have a look at the related packages <a href="https://cran.r-project.org/package=MeshesTools"><code>MeshesTools</code></a>, and <a href="https://cran.r-project.org/package=PolygonSoup"><code>PolygonSoup</code></a>.</p>
<p><img src="tiger.gif" height = "500" width="500" alt="Alpha hull of points forming a torus"></p>
<p><a href="https://cran.r-project.org/package=bangladesh">bangladesh</a> v1.0.0: Provides <code>sf</code> objects, shape files, and functions to draw regional chorpleth maps for Bangladesh. See the <a href="https://cran.r-project.org/web/packages/bangladesh/vignettes/introduction.html">vignette</a>.</p>
<p><img src="bangladesh.png" height = "500" width="500" alt="District level chorpleth plot of Bangladesh"></p>
<p><a href="https://cran.r-project.org/package=ggstats">ggstats</a> v0.1.0: Provides functions to create forest plots of regression model coefficients along with new statistics to compute proportions, weighted mean and cross-tabulation statistics, as well as new geometries to add alternative background color to a plot. There are vignettes on <a href="https://cran.r-project.org/web/packages/ggstats/vignettes/ggcoef_model.html">plotting coefficients</a> and on computing <a href="https://cran.r-project.org/web/packages/ggstats/vignettes/stat_cross.html">cross-tabulation</a>, <a href="https://cran.r-project.org/web/packages/ggstats/vignettes/stat_prop.html">custom proportions</a>, and <a href="https://cran.r-project.org/web/packages/ggstats/vignettes/stat_weighted_mean.html">weighted means</a>.</p>
<p><img src="ggstats.png" height = "400" width="400" alt="Forest plot"></p>
<p><a href="https://cran.r-project.org/package=jagshelper">jagshelper</a> v0.1.11: Provides tools to streamline Bayesian analyses in <code>JAGS</code>including functions for extracting output, streamlining assessment of convergence, and producing summary plots. See the <a href="https://cran.r-project.org/web/packages/jagshelper/vignettes/jagshelper-vignette.html">vignette</a> for examples.</p>
<p><img src="jagshelper.png" height = "500" width="500" alt="JAGS trace plots"></p>
<p><a href="https://cran.r-project.org/package=roughsf">roughsf</a> v1.0.0: Provides functions to draw maps, including “sketchy”, hand-drawn-like maps using the Javascript library <a href="https://roughjs.com/"><code>Roughjs</code></a>. See <a href="https://cran.r-project.org/web/packages/roughsf/readme/README.html">README</a> for examples.</p>
<p><img src="roughjs.png" height = "600" width="800" alt="Sketchy world map"></p>
<script>window.location.href='https://rviews.rstudio.com/2022/11/28/october-2022-top-40-new-cran-packages/';</script>
Analyzing Projected Calculations Using R
https://rviews.rstudio.com/2022/11/21/projected-inventory-calculations-using-r-2/
Mon, 21 Nov 2022 00:00:00 +0000https://rviews.rstudio.com/2022/11/21/projected-inventory-calculations-using-r-2/
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/core-js/shim.min.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/react/react.min.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/react/react-dom.min.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/reactwidget/react-tools.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/htmlwidgets/htmlwidgets.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/reactable-binding/reactable.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/jquery/jquery.min.js"></script>
<link href="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/jquery-sparkline/jquery.sparkline.css" rel="stylesheet" />
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/jquery-sparkline/jquery.sparkline.js"></script>
<script src="/2022/11/21/projected-inventory-calculations-using-r-2/index_files/sparkline-binding/sparkline.js"></script>
<p><br>
<em>Nicolas Nguyen works in the Supply Chain industry, in the area of Demand and Supply Planning, S&OP and Analytics, where he enjoys developing solutions using R and Shiny. Outside his job, he teaches data visualization in R at the Engineering School EIGSI and Business School Excelia in the city of La Rochelle, France.</em></p>
<div id="introduction" class="section level1">
<h1>Introduction</h1>
<p>Demand & Supply Planning requires forecasting techniques to determine the inventory needed to fulfill future orders. We can build end-to-end supply chain monitoring processes with R to identify potential issues and run scenario testing.</p>
<p>In a 3-part series, I will walk through a Demand & Supply Planning workflow.</p>
<ol style="list-style-type: decimal">
<li>In October, we published the first post, <a href="https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/">Using R for Projected Inventory Calculations in Demand & Supply Planning</a>. It is an introduction to projected inventory and coverage methodology. Check it out if you haven’t read it yet!</li>
<li>This post, Analyzing Projected Calculations Using R, presents an analysis of a demo dataset using the <strong>planr package</strong>.</li>
<li>The final post, Visualizing Projected Calculations with reactable and Shiny, will answer the question: how would you present your results to your boss once the analysis is done?</li>
</ol>
<p>By the end of the series, you will understand how and why to use R for Demand & Supply Planning calculations. Let’s continue!</p>
<div id="the-problem-we-aim-to-solve" class="section level2">
<h2>The “problem” we aim to solve</h2>
<p>In Demand & Supply Planning, we often need to calculate <strong>projected inventories</strong> (inventory needed to fulfill future orders) and <strong>projected coverages</strong> (demand needed to cover periods of time). In my previous post, we discussed the methodology behind these calculations. If you haven’t read it, <a href="https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/">click here</a>!</p>
<p>This post will focus on analyzing a demo dataset using the <code>proj_inv()</code> function from the <a href="https://github.com/nguyennico/planr"><strong>planr package</strong></a>. This function calculates projected inventories and coverages with also some analysis features. Then, we can apply the projected inventories & coverages methodology to analyze our data using R!</p>
</div>
<div id="demand-supply-planning-datasets" class="section level2">
<h2>Demand & Supply Planning datasets</h2>
<p>A typical Demand & Supply Planning dataset has the following basic elements, which are essential to calculate projected inventories & coverages:</p>
<ul>
<li>An Item (a SKU or a DFU) or a reference (a group/family of SKUs for example)</li>
<li>A Period</li>
<li>An Opening Inventories</li>
<li>Then a Demand and a Supply Plan</li>
</ul>
<p>We can also add more features, such as stocks parameters expressed in units, coverages, or a combination of both (for example, ensuring a minimum of one month coverage, and also at least two units of stocks).</p>
</div>
<div id="overview-of-the-demo-dataset" class="section level2">
<h2>Overview of the demo dataset</h2>
<p>To illustrate a typical Demand & Supply Planning dataset, we can use the demo dataset, [Blueprint_DB]. This dataset contains dummy data that displays common situations in Demand and Supply Planning (alerts, shortages, overstocks, etc.). [Blueprint_DB] also contains data for the most common type of coverage, minimum and maximum targets.</p>
<p>We can upload the dataset directly from the <a href="https://github.com/nguyennico/planr">planr package</a>:</p>
<pre class="r"><code>library(tidyr)
library(dplyr)
library(stringr)
library(lubridate)</code></pre>
<pre><code>##
## Attaching package: 'lubridate'</code></pre>
<pre><code>## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union</code></pre>
<pre class="r"><code>library(planr)
library(ggplot2)
Blueprint_DB <- planr::blueprint</code></pre>
<pre class="r"><code>glimpse(Blueprint_DB)</code></pre>
<pre><code>## Rows: 520
## Columns: 7
## $ DFU <chr> "Item 000001", "Item 000002", "Item 000003", "Item…
## $ Period <date> 2022-07-03, 2022-07-03, 2022-07-03, 2022-07-03, 2…
## $ Demand <dbl> 364, 1419, 265, 1296, 265, 1141, 126, 6859, 66, 38…
## $ Opening.Inventories <dbl> 6570, 5509, 2494, 7172, 1464, 9954, 2092, 17772, 1…
## $ Supply.Plan <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ Min.Stocks.Coverage <dbl> 4, 4, 4, 6, 4, 6, 4, 6, 4, 4, 4, 4, 4, 6, 4, 6, 4,…
## $ Max.Stocks.Coverage <dbl> 8, 6, 12, 6, 12, 6, 8, 10, 12, 12, 8, 6, 12, 6, 12…</code></pre>
<p>The dataset has seven fields: Demand Forecast Unit (DFU), Period, Demand, Opening Inventories, Supply Plan, Minimum Stocks Coverage, and Maximum Stocks Coverage. We can use a reactable table to look through all the information at once. This helps us get a sense of the distribution of the data and what it looks like for each variable over time. (Code for the table below is in the <a href="#appendix">Appendix</a>.)</p>
<div id="htmlwidget-1" class="reactable html-widget" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-1">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"DFU":["Item 000001","Item 000002","Item 000003","Item 000004","Item 000005","Item 000006","Item 000007","Item 000008","Item 000009","Item 000010"],"Total.Demand":[14923,25060,5975,28289,3108,54470,7676,114532,3177,7096],"Opening.Inventories":[6570,5509,2494,7172,1464,9954,2092,17772,1222,3411],"Supply.Plan":[6187,17927,3000,20000,1187,21660,6347,51450,791,4440],"Min.Stocks.Coverage":[4,4,4,6,4,6,4,6,4,4],"Max.Stocks.Coverage":[8,6,12,6,12,6,8,10,12,12],"Demand.Quantity":[[364,364,364,260,736,859,859,859,273,349,349,349,200,0,0,0,0,367,514,514,514,506,837,837,837,479,69,62,52,82,107,187,187,187,81,73,0,0,27,187,187,187,161,161,187,187,187,107,187,187,187,107],[1419,1419,1419,1014,721,841,841,841,1160,2427,2427,2427,1502,807,807,807,692,510,714,714,714,216,28,28,28,16,26,26,26,26,0,0,0,0,16,28,28,28,18,39,39,39,33,21,24,24,24,9,13,13,13,8],[265,265,265,189,29,34,34,34,23,42,42,42,50,178,178,178,152,24,34,34,34,41,72,72,72,42,243,243,243,243,90,156,156,156,150,145,145,145,83,145,145,145,124,46,53,53,53,70,145,145,145,83],[1296,1296,1296,926,678,791,791,791,560,1042,1042,1042,785,1329,1329,1329,1139,1452,2032,2032,2032,653,169,169,169,97,96,96,96,96,42,72,72,72,72,72,72,72,48,121,121,121,103,62,72,72,72,42,72,72,72,42],[265,265,265,189,59,69,69,69,40,69,69,69,49,69,69,69,59,49,69,69,69,49,69,69,69,40,31,31,31,31,18,31,31,31,31,31,31,31,18,31,31,31,26,26,31,31,31,18,31,31,31,18],[1141,1141,1141,815,1466,1711,1711,1711,943,1630,1630,1630,1176,1711,1711,1711,1466,1222,1711,1711,1711,489,823,702,697,919,816,608,726,716,532,904,978,698,990,617,880,938,779,713,628,959,617,561,656,949,843,558,971,821,627,955],[126,126,126,90,325,379,379,379,251,460,460,460,309,325,325,325,278,78,109,109,109,43,28,28,28,16,81,77,95,97,63,91,97,65,92,78,62,60,92,69,98,85,83,88,70,61,62,51,64,74,61,89],[6859,6859,6859,4900,1358,1585,1585,1585,2023,4191,4191,4191,3230,5841,5841,5841,5007,2452,3432,3432,3432,1999,2376,2376,2376,1358,744,850,500,903,802,596,683,864,768,713,637,688,670,759,918,773,722,867,655,994,689,777,742,576,776,687],[66,66,66,48,85,100,100,100,15,54,54,90,65,98,98,51,82,48,66,66,66,19,89,72,83,88,66,66,66,66,0,0,0,0,38,66,66,66,29,59,72,52,97,84,73,51,60,29,66,66,66,38],[380,380,380,272,169,197,197,197,93,151,151,151,103,117,117,117,100,70,97,97,97,81,123,123,123,71,271,271,271,271,77,134,134,134,96,67,67,67,39,73,73,73,63,110,128,128,128,45,62,62,62,36]],"Supply.Quantity":[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,5000,0,0,0,0,0,0,0,1187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,10367,0,0,0,0,4753,0,0,0,0,1944,647,0,0,0,0,0,0,0,216,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,10000,0,0,0,0,0,0,0,0,0,0,0,0,10000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,1187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,7980,0,0,0,0,9576,0,0,0,0,4104,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,2593,0,0,0,0,0,0,0,0,0,107,540,0,0,0,0,0,107,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,12012,0,10000,0,0,0,1453,2244,0,0,0,16104,9504,0,0,0,0,0,0,0,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,0,0,0,0,0,0,0,264,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,600,0,0,0,0,0,0,1920,1920,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]},"columns":[{"accessor":"DFU","name":"Item","type":"character","footerStyle":{"fontWeight":"bold"},"minWidth":150},{"accessor":"Total.Demand","name":"Total Demand (units)","type":"numeric","footerStyle":{"fontWeight":"bold"},"aggregate":"sum","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"footer":"264,306","style":{"background":"yellow","fontWeight":"bold"}},{"accessor":"Opening.Inventories","name":"Opening Inventories (units)","type":"numeric","footerStyle":{"fontWeight":"bold"},"aggregate":"sum","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"footer":"57,660"},{"accessor":"Supply.Plan","name":"Supply Plan (units)","type":"numeric","footerStyle":{"fontWeight":"bold"},"aggregate":"sum","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"footer":"132,989"},{"accessor":"Min.Stocks.Coverage","name":"Min Stocks Coverage (periods)","type":"numeric","footerStyle":{"fontWeight":"bold"},"cell":[{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#32CD32FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"4"]}]}]}]},{"accessor":"Max.Stocks.Coverage","name":"Max Stocks Coverage (periods)","type":"numeric","footerStyle":{"fontWeight":"bold"},"cell":[{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"8"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"50%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"12"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"50%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"12"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"50%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"6"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"66.6666666666667%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"8"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"83.3333333333333%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"10"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"12"]}]}]},{"name":"div","attribs":{},"children":[{"name":"div","attribs":{"style":{"flexGrow":1,"borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","background":"#EEEEEE"}},"children":[{"name":"div","attribs":{"style":{"display":"flex","alignItems":"center","color":"black","fontSize":null,"fontWeight":"normal"}},"children":[{"name":"div","attribs":{"style":{"alignText":"right","display":"flex","alignItems":"center","justifyContent":"flex-end","borderTopLeftRadius":"0px","borderBottomLeftRadius":"0px","borderTopRightRadius":"0px","borderBottomRightRadius":"0px","boxShadow":null,"border":" ","background":"#FFA500FF","backgroundImage":null,"width":"100%","height":18,"transition":"width 1s ease","marginRight":"6px"}},"children":[]},"12"]}]}]}]},{"accessor":"Demand.Quantity","name":"Demand","type":"list","footerStyle":{"fontWeight":"bold"},"cell":[{"name":"WidgetContainer","attribs":{"key":"72cfaa63122f5ab8d7ff38af88c1a2e6"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-286176d9aaef22187807","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-286176d9aaef22187807"},"children":["{\"x\":{\"values\":[364,364,364,260,736,859,859,859,273,349,349,349,200,0,0,0,0,367,514,514,514,506,837,837,837,479,69,62,52,82,107,187,187,187,81,73,0,0,27,187,187,187,161,161,187,187,187,107,187,187,187,107],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"d6c37793c595d31280d022e42ad176d7"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-c8ca5b092cc0b1d827d8","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-c8ca5b092cc0b1d827d8"},"children":["{\"x\":{\"values\":[1419,1419,1419,1014,721,841,841,841,1160,2427,2427,2427,1502,807,807,807,692,510,714,714,714,216,28,28,28,16,26,26,26,26,0,0,0,0,16,28,28,28,18,39,39,39,33,21,24,24,24,9,13,13,13,8],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"9f40eb22c8ab2f3cdde3c2d68f5e46ee"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-2f8d3817a6cd0f0090ca","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-2f8d3817a6cd0f0090ca"},"children":["{\"x\":{\"values\":[265,265,265,189,29,34,34,34,23,42,42,42,50,178,178,178,152,24,34,34,34,41,72,72,72,42,243,243,243,243,90,156,156,156,150,145,145,145,83,145,145,145,124,46,53,53,53,70,145,145,145,83],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"b810fc56c1d7ba11067bc61458614835"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-2b434704c825c0c84d4a","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-2b434704c825c0c84d4a"},"children":["{\"x\":{\"values\":[1296,1296,1296,926,678,791,791,791,560,1042,1042,1042,785,1329,1329,1329,1139,1452,2032,2032,2032,653,169,169,169,97,96,96,96,96,42,72,72,72,72,72,72,72,48,121,121,121,103,62,72,72,72,42,72,72,72,42],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"d50d949d1e1dfde687cfd4a5cd3f7a58"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-49367c76be9de80e88b8","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-49367c76be9de80e88b8"},"children":["{\"x\":{\"values\":[265,265,265,189,59,69,69,69,40,69,69,69,49,69,69,69,59,49,69,69,69,49,69,69,69,40,31,31,31,31,18,31,31,31,31,31,31,31,18,31,31,31,26,26,31,31,31,18,31,31,31,18],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"2469dfd0697abbae86a8eb7feeef0cf1"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-19707e0c299c1fe7284f","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-19707e0c299c1fe7284f"},"children":["{\"x\":{\"values\":[1141,1141,1141,815,1466,1711,1711,1711,943,1630,1630,1630,1176,1711,1711,1711,1466,1222,1711,1711,1711,489,823,702,697,919,816,608,726,716,532,904,978,698,990,617,880,938,779,713,628,959,617,561,656,949,843,558,971,821,627,955],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"1761bac430fd3b5ac598602a6266c26f"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-9d22d078cf760b41a56a","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-9d22d078cf760b41a56a"},"children":["{\"x\":{\"values\":[126,126,126,90,325,379,379,379,251,460,460,460,309,325,325,325,278,78,109,109,109,43,28,28,28,16,81,77,95,97,63,91,97,65,92,78,62,60,92,69,98,85,83,88,70,61,62,51,64,74,61,89],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"97fac4b0c065ed9f20ced019fd143e20"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-7fd0683c3f56ce3a8b15","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-7fd0683c3f56ce3a8b15"},"children":["{\"x\":{\"values\":[6859,6859,6859,4900,1358,1585,1585,1585,2023,4191,4191,4191,3230,5841,5841,5841,5007,2452,3432,3432,3432,1999,2376,2376,2376,1358,744,850,500,903,802,596,683,864,768,713,637,688,670,759,918,773,722,867,655,994,689,777,742,576,776,687],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"125b46e4c01e00cc19b19361625bb699"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-f9a663ecc80b02dc9639","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-f9a663ecc80b02dc9639"},"children":["{\"x\":{\"values\":[66,66,66,48,85,100,100,100,15,54,54,90,65,98,98,51,82,48,66,66,66,19,89,72,83,88,66,66,66,66,0,0,0,0,38,66,66,66,29,59,72,52,97,84,73,51,60,29,66,66,66,38],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"b29ceff6d16ffc2c07a21d178084dacb"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-37fa2faf555c29f20e1e","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-37fa2faf555c29f20e1e"},"children":["{\"x\":{\"values\":[380,380,380,272,169,197,197,197,93,151,151,151,103,117,117,117,100,70,97,97,97,81,123,123,123,71,271,271,271,271,77,134,134,134,96,67,67,67,39,73,73,73,63,110,128,128,128,45,62,62,62,36],\"options\":{\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]}]},{"accessor":"Supply.Quantity","name":"Supply","type":"list","footerStyle":{"fontWeight":"bold"},"cell":[{"name":"WidgetContainer","attribs":{"key":"07b138716a3cf41be9130b5b5fa9edb3"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-d212a496ae9cb2324936","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-d212a496ae9cb2324936"},"children":["{\"x\":{\"values\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,5000,0,0,0,0,0,0,0,1187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"9ea7597f50490c1f2c3f98af110e1ccd"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-d658f03f5bcac23a434d","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-d658f03f5bcac23a434d"},"children":["{\"x\":{\"values\":[0,0,0,10367,0,0,0,0,4753,0,0,0,0,1944,647,0,0,0,0,0,0,0,216,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"dba73d4bf4f78a11ad8472476864cc6e"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-abfd96274ffd65cae594","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-abfd96274ffd65cae594"},"children":["{\"x\":{\"values\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"658b79ee13aa9116c0a38a51b303eecc"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-cdfdec785fa2e5219a34","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-cdfdec785fa2e5219a34"},"children":["{\"x\":{\"values\":[0,0,0,0,0,0,0,10000,0,0,0,0,0,0,0,0,0,0,0,0,10000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"ddaf59c2449cc8d76f0862ff3844d3fe"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-a19a8aa6d6f30ba116bf","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-a19a8aa6d6f30ba116bf"},"children":["{\"x\":{\"values\":[0,0,0,0,0,0,0,0,1187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"1768fb15b7a64f3bece8fe3ce1cb7d3a"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-0bbc09fb98b19a55d2d5","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-0bbc09fb98b19a55d2d5"},"children":["{\"x\":{\"values\":[0,0,0,7980,0,0,0,0,9576,0,0,0,0,4104,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"51d76a1a07dbcd8280542a734bdd1345"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-eed665fade302e045ecd","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-eed665fade302e045ecd"},"children":["{\"x\":{\"values\":[0,0,0,2593,0,0,0,0,0,0,0,0,0,107,540,0,0,0,0,0,107,0,0,0,0,0,0,0,3000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"e54ee6a6dfa6e45afe6d65e5fa99d348"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-2a75f575441b7c127711","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-2a75f575441b7c127711"},"children":["{\"x\":{\"values\":[0,0,12012,0,10000,0,0,0,1453,2244,0,0,0,16104,9504,0,0,0,0,0,0,0,133,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"e941a1979383ecbaa24bfeda0327ea65"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-e83738cc4e541489fafb","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-e83738cc4e541489fafb"},"children":["{\"x\":{\"values\":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,527,0,0,0,0,0,0,0,264,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]},{"name":"WidgetContainer","attribs":{"key":"f9565d840b83278dcd3a1e0a5a509292"},"children":[{"name":"Fragment","attribs":[],"children":[{"name":"span","attribs":{"id":"htmlwidget-8cd3e10c250baa0040e4","className":"sparkline html-widget"},"children":[]},{"name":"script","attribs":{"type":"application/json","data-for":"htmlwidget-8cd3e10c250baa0040e4"},"children":["{\"x\":{\"values\":[0,0,0,0,0,600,0,0,0,0,0,0,1920,1920,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"options\":{\"type\":\"bar\",\"height\":20,\"width\":60},\"width\":60,\"height\":20},\"evals\":[],\"jsHooks\":[]}"]}]}]}]}],"columnGroups":[{"name":"Demand & Supply Inputs","columns":["Total.Demand","Opening.Inventories","Supply.Plan"]},{"name":"Stocks Targets Parameters","columns":["Min.Stocks.Coverage","Max.Stocks.Coverage"]}],"defaultSorted":[{"id":"DFU","desc":false}],"defaultPageSize":20,"paginationType":"numbers","showPageInfo":true,"minRows":1,"compact":true,"dataKey":"b521d018f6d9685874155c418af25623"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<p>[<strong>Table 1:</strong> Display of [Blueprint_DB] Data by Column]</p>
<p>Let’s go through each of these columns.</p>
<ul>
<li><strong>DFU</strong>: this is a single product (also called SKU, “Storage Keeping Unit”) with certain characteristics. For example, a SKU sold in one particular distribution channel. In this dataset, we have <strong>10 items</strong>.</li>
</ul>
<pre class="r"><code>unique(Blueprint_DB$DFU)</code></pre>
<pre><code>## [1] "Item 000001" "Item 000002" "Item 000003" "Item 000004" "Item 000005"
## [6] "Item 000006" "Item 000007" "Item 000008" "Item 000009" "Item 000010"</code></pre>
<ul>
<li><strong>Period</strong>: the horizon of time during which we will project our inventories calculation. It could be monthly, weekly, daily (and so on) buckets, over a certain range, for example, 24 months or 52 weeks. In this case, it is a <strong>weekly</strong> bucket over <strong>52 weeks</strong>.</li>
</ul>
<pre class="r"><code>range(Blueprint_DB$Period)</code></pre>
<pre><code>## [1] "2022-07-03" "2023-06-25"</code></pre>
<ul>
<li><strong>Demand</strong>: the Demand Forecast for each period of time, expressed in units.
<ul>
<li>For example, this could be Sales Forecasts or Replenishment Forecasts (if we ship to one warehouse to replenish it).</li>
</ul></li>
</ul>
<p>Looking at the Demand, there’s a range from no demand for units to a demand of 6859 units.</p>
<pre class="r"><code>summary(Blueprint_DB$Demand)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 62 119 508 690 6859</code></pre>
<ul>
<li><strong>Opening Inventories</strong>: our available stocks at the beginning of the horizon, expressed in units.</li>
</ul>
<p>The first date in our Period is 2022-07-03. Let’s take a look at the summary statistics, where we can see the range of opening inventory from 1222 to 17,772 units:</p>
<pre class="r"><code>July_03 <- Blueprint_DB %>% filter(Period == "2022-07-03")
summary(July_03$Opening.Inventories)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1222 2192 4460 5766 7022 17772</code></pre>
<ul>
<li><strong>Supply Plan</strong>: the quantities that we will receive to replenish our stocks at a given time, expressed in units.</li>
</ul>
<p>The replenishment amount in the Supply Plan ranges from no replenishment to replenishment of over 16,000 units.</p>
<pre class="r"><code>summary(Blueprint_DB$Supply.Plan)</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0 0 0 256 0 16104</code></pre>
<ul>
<li><strong>Minimum Stocks Coverage</strong>: a parameter of minimum stocks expressed in the number of periods of coverage.
<ul>
<li>For example, if we put two months, we aim to maintain a minimum stock coverage of two months, based on the Demand Forecasts.</li>
</ul></li>
<li><strong>Maximum Stocks Coverage</strong>: a parameter of maximum stocks expressed in the number of coverage periods.
<ul>
<li>If we put six months, it means that we aim to maintain our stocks below the coverage of six months, based on the Demand Forecasts.</li>
</ul></li>
</ul>
<p>Some items, like “Item 000004” have the same min and max stocks coverage throughout the period. Other items, like “Item 000009” have variable min and max stocks coverage over time.</p>
<p>It’s always helpful to look at a specific item to better understand the data. We want to ensure it contains all the information that we need:</p>
<ul>
<li><strong>Dimensions</strong>: [DFU] and [Period]</li>
<li><strong>Demand and Supply Planning Values</strong>: [Demand] / [Opening Inventories] / [Supply Plan]</li>
<li><strong>(Target) Stocks Levels</strong>: [Min.Stocks.Coverage] and [Max.Stocks.Coverage]</li>
</ul>
<p>For example, let’s look closer at “Item 000008” and verify all the information is there:</p>
<pre class="r"><code>Item_000008 <- filter(Blueprint_DB, Blueprint_DB$DFU == "Item 000008")
summary(Item_000008)</code></pre>
<pre><code>## DFU Period Demand Opening.Inventories
## Length:52 Min. :2022-07-03 Min. : 500 Min. : 0
## Class :character 1st Qu.:2022-09-30 1st Qu.: 744 1st Qu.: 0
## Mode :character Median :2022-12-28 Median :1176 Median : 0
## Mean :2022-12-28 Mean :2203 Mean : 342
## 3rd Qu.:2023-03-27 3rd Qu.:3432 3rd Qu.: 0
## Max. :2023-06-25 Max. :6859 Max. :17772
## Supply.Plan Min.Stocks.Coverage Max.Stocks.Coverage
## Min. : 0 Min. :6 Min. :10
## 1st Qu.: 0 1st Qu.:6 1st Qu.:10
## Median : 0 Median :6 Median :10
## Mean : 989 Mean :6 Mean :10
## 3rd Qu.: 0 3rd Qu.:6 3rd Qu.:10
## Max. :16104 Max. :6 Max. :10</code></pre>
<p>Looking at our summary statistics, we see:</p>
<ul>
<li>Our [DFU] is “Item 000008”.</li>
<li>We have a [Period] of 52 weeks from 2022-07-03 until 2023-07-03.</li>
<li>The [Opening Inventory] is 17,772 units.</li>
<li>[Demand] ranges from 500 to 6859 units, with an average of 2203 units.</li>
<li>[Supply] ranges from 0 to 16,104 units, with an average of 989 units.</li>
<li>In this case, the [Min.Stocks.Coverage] coverage is constant at 6 units, and the [Max.Stocks.Coverage] is constant at 10.</li>
</ul>
<p>Great, we have what we need!</p>
<p>This was an overview of a standard, complete, and tidy database, ready to be used for a Demand & Supply planning calculation. All the needed elements are there, organized in three groups of data: Dimensions / Demand & Supply Planning Values / Stocks Levels. Now, we can move on to our calculations!</p>
</div>
<div id="calculation-of-the-projected-inventories" class="section level2">
<h2>Calculation of the Projected Inventories</h2>
<p>We are going to calculate two things, applying the methodology we saw previously (read about it in the <a href="https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/">previous post of the series</a>):</p>
<ul>
<li><strong>Projected Inventories</strong>
<ul>
<li>Definition: [Stocks at the beginning of a Period of time] - [Demand of the Period] + [Supply Plan to be received during this Period]</li>
<li>At the very beginning: [Stocks at the beginning of a Period of time] = [Opening Inventories]</li>
</ul></li>
<li><strong>Related Projected Coverages</strong>
<ul>
<li>Definition: how many periods of Demand (forecasts) do the Projected Inventories of a Period of time cover</li>
</ul></li>
</ul>
<p>Using R means that the analysis can be simple and fast. It provides us with a summary view of the portfolio, and then we can zoom in on the items with risks of shortages or overstocks.</p>
</div>
<div id="run-proj_inv" class="section level2">
<h2>Run <code>proj_inv()</code></h2>
<p>To see how simple and fast it can be to calculate projected inventories and coverages, let’s apply the function <code>proj_inv()</code> from the planr package to the whole demo dataset to create this summary view:</p>
<pre class="r"><code># Create a calculated database for the Projected Inventories @ DFU level
Calculated_DB <- proj_inv(
data = Blueprint_DB,
DFU = DFU,
Period = Period,
Demand = Demand,
Opening.Inventories = Opening.Inventories,
Supply.Plan = Supply.Plan,
Min.Stocks.Coverage = Min.Stocks.Coverage,
Max.Stocks.Coverage = Max.Stocks.Coverage
)</code></pre>
<p>Let’s have a look at the output’s column headers:</p>
<pre class="r"><code>colnames(Calculated_DB)</code></pre>
<pre><code>## [1] "DFU" "Period"
## [3] "Demand" "Opening.Inventories"
## [5] "Calculated.Coverage.in.Periods" "Projected.Inventories.Qty"
## [7] "Supply.Plan" "Min.Stocks.Coverage"
## [9] "Max.Stocks.Coverage" "Safety.Stocks"
## [11] "Maximum.Stocks" "PI.Index"
## [13] "Ratio.PI.vs.min" "Ratio.PI.vs.Max"</code></pre>
<p>After the calculation using <code>proj_inv()</code>, we have new columns that give us a complete database for automated analysis.</p>
<ul>
<li><strong>1st group: Calculated Columns</strong>
<ul>
<li><code>Projected.Inventories.Qty</code>: Calculation of projected inventories</li>
<li><code>Calculated.Coverage.in.Periods</code>: Calculation of coverages in number of periods</li>
<li><code>Safety.Stocks</code> and <code>Maximum.Stocks</code>: Projected Stocks Targets (minimum & maximum) in units, useful for further analysis</li>
</ul></li>
<li><strong>2nd group: Analysis Features</strong>
<ul>
<li>To automate screening and facilitate the decision taking process:
<ul>
<li><code>PI.Index</code>: Projected Inventories Index: basically, how the [projected inventories] are doing (OK, alert, shortage, overstocks)</li>
<li><code>Ratio.PI.vs.min</code>: A ratio [Projected Inventories] vs. [Minimum Stocks Target]: used with a threshold filter, it allows us to identify the relevant SKUs quickly</li>
<li><code>Ratio.PI.vs.Max</code>: A ratio [Projected Inventories] vs. [Maximum Stocks Target], same as above</li>
</ul></li>
</ul></li>
</ul>
<p>Once we have run <code>proj_inv()</code>, we can <strong>automate the screening of our demand & supply</strong>. We can quickly know if we need to change our inventories and how to do so. This is very powerful as it means we can easily adjust based on Demand & Supply.</p>
</div>
<div id="results-from-proj_inv" class="section level2">
<h2>Results from <code>proj_inv()</code></h2>
<p>Let’s revisit “Item 000008” using this new dataset with calculated columns using the reactable package:</p>
<div id="htmlwidget-2" class="reactable html-widget" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-2">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"DFU":["Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008","Item 000008"],"Period":["2022-07-03","2022-07-10","2022-07-17","2022-07-24","2022-07-31","2022-08-07","2022-08-14","2022-08-21","2022-08-28","2022-09-04","2022-09-11","2022-09-18","2022-09-25","2022-10-02","2022-10-09","2022-10-16","2022-10-23","2022-10-30","2022-11-06","2022-11-13","2022-11-20","2022-11-27"],"Demand":[6859,6859,6859,4900,1358,1585,1585,1585,2023,4191,4191,4191,3230,5841,5841,5841,5007,2452,3432,3432,3432,1999],"Opening.Inventories":[17772,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Calculated.Coverage.in.Periods":[1.6,0.6,3.9,2.9,5.5,4.5,3.5,2.5,1.8,1.4,0.4,0,0,0.7,1.4,0.4,0,0,0,0,0,0],"Projected.Inventories.Qty":[10913,4054,9207,4307,12949,11364,9779,8194,7624,5677,1486,-2705,-5935,4328,7991,2150,-2857,-5309,-8741,-12173,-15605,-17604],"Supply.Plan":[0,0,12012,0,10000,0,0,0,1453,2244,0,0,0,16104,9504,0,0,0,0,0,0,0],"Min.Stocks.Coverage":[6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],"Max.Stocks.Coverage":[10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10],"Safety.Stocks":[23146,17872,13036,12327,15160,17766,19411,23667,27485,29135,29951,28212,28414,26005,23596,19754,17123,17047,15991,13917,11229,10080],"Maximum.Stocks":[35136,32468,28839,29780,34263,38519,41941,42808,44217,43458,42699,40507,39653,36188,32723,28240,23977,22375,19443,16914,14284,12881],"PI.Index":["Alert","Alert","Alert","Alert","Alert","Alert","Alert","Alert","Alert","Alert","Alert","Shortage","Shortage","Alert","Alert","Alert","Shortage","Shortage","Shortage","Shortage","Shortage","Shortage"],"Ratio.PI.vs.min":[0.47,0.23,0.71,0.35,0.85,0.64,0.5,0.35,0.28,0.19,0.05,-0.1,-0.21,0.17,0.34,0.11,-0.17,-0.31,-0.55,-0.87,-1.39,-1.75],"Ratio.PI.vs.Max":[0.31,0.12,0.32,0.14,0.38,0.3,0.23,0.19,0.17,0.13,0.03,-0.07,-0.15,0.12,0.24,0.08,-0.12,-0.24,-0.45,-0.72,-1.09,-1.37]},"columns":[{"accessor":"DFU","name":"DFU","type":"character"},{"accessor":"Period","name":"Period","type":"Date"},{"accessor":"Demand","name":"Demand","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}}},{"accessor":"Opening.Inventories","name":"Opening Inventories","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}}},{"accessor":"Calculated.Coverage.in.Periods","name":"Calculated Coverage in Periods","type":"numeric","style":{"background":"yellow"}},{"accessor":"Projected.Inventories.Qty","name":"Projected Inventories Qty","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"style":{"background":"yellow"}},{"accessor":"Supply.Plan","name":"Supply Plan","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}}},{"accessor":"Min.Stocks.Coverage","name":"Min.Stocks.Coverage","type":"numeric"},{"accessor":"Max.Stocks.Coverage","name":"Max.Stocks.Coverage","type":"numeric"},{"accessor":"Safety.Stocks","name":"Safety Stocks","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"style":{"background":"lightgreen"}},{"accessor":"Maximum.Stocks","name":"Maximum Stocks","type":"numeric","format":{"cell":{"digits":0,"separators":true},"aggregated":{"digits":0,"separators":true}},"style":{"background":"lightgreen"}},{"accessor":"PI.Index","name":"PI Index","type":"character","style":{"background":"lightblue"}},{"accessor":"Ratio.PI.vs.min","name":"Ratio PI vs min","type":"numeric","style":{"background":"lightblue"}},{"accessor":"Ratio.PI.vs.Max","name":"Ratio PI vs Max'","type":"numeric","style":{"background":"lightblue"}}],"columnGroups":[{"name":"Calculation of Projected Inventories & Coverages","columns":["Calculated.Coverage.in.Periods","Projected.Inventories.Qty"]},{"name":"Projected Stocks Targets","columns":["Safety.Stocks","Maximum.Stocks"]},{"name":"Analysis Features","columns":["PI.Index","Ratio.PI.vs.min","Ratio.PI.vs.Max"]}],"defaultPageSize":10,"paginationType":"numbers","showPageInfo":true,"minRows":1,"highlight":true,"striped":true,"compact":true,"dataKey":"4d36232456dac5840d2dbc25cf962225"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<p><span class="smallcaps"><strong>Table 2:</strong> The results after applying the <code>proj_inv()</code> function.</span></p>
<p>The new columns in yellow, green, and blue colors have been calculated and added to the original database. We can quickly scan through “Item 000008” for any particular period and notice information such as:</p>
<ul>
<li>The calculated coverage on 2022-07-03 is 1.6 (based on Upcoming Demand, we expect our inventory to last 1.6 weeks). The next week, it is 0.6.</li>
<li>From 2022-07-03 to 2022-09-11, we should be on Alert that we will fall below our minimum stock inventory. On 2022-09-18, we fall into shortage.</li>
</ul>
<p>We can find specific numbers for each Period by scrolling through the table. That is just from <code>proj_inv()</code>, without having to do any manual calculations or corrections.</p>
<p>Outside the analysis features, <code>proj_inv()</code> is very fast. Below are calculations of the speed on a Windows 10 x64 release. If we manage a portfolio of 200 SKUs over a 52 weeks horizon (weekly bucket), the calculation and analysis are done in only 5 seconds. The calculation is still pretty fast, up to 500 SKUs, which makes it quite handy if we want to run some simulations straight in Shiny.</p>
<div class="figure">
<img src="image008.png" alt="" />
<p class="caption">Chart of a classic range and size of Demand Planning or S&OP Portfolio</p>
</div>
<p>When we work on the S&OP (Sales & Operations Planning) Process, we work at an aggregated level (production families of products) and in monthly buckets. There are limited numbers of items and the horizon is typically 24 months. We can use the <code>proj_inv()</code> function to quickly calculate and analyze the projected inventories & coverages through a (sometimes complex) supply chain network at the same time.</p>
</div>
<div id="learn-more" class="section level2">
<h2>Learn more</h2>
<p>Thank you for reading this walkthrough of applying <code>proj_inv()</code> on a Demand & Supply Planning dataset! I hope you see what is needed to run projected inventory calculations, and how a single function in R can provide important information on projected inventories and coverages.</p>
<p>The reactable package makes quick, easy, pretty tables that are easy to sort and scan. What if we want to show more visual information, like color highlighting and charts?</p>
<p>…let’s find out in the next blog post..!</p>
<p>In the meantime, here are some useful links:</p>
<ul>
<li>Previous post: <a href="https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/">Using R for Projected Inventory Calculations in Demand & Supply Planning</a></li>
<li><strong>planr package</strong> GitHub repository: <a href="https://github.com/nguyennico/planr" class="uri">https://github.com/nguyennico/planr</a></li>
<li>URL for a Shiny app showing a demo of the <code>proj_inv()</code> and <code>light_proj_inv()</code> functions: <a href="https://niconguyen.shinyapps.io/Projected_Inventories/">Demo: app proj_inv() function (shinyapps.io)</a></li>
</ul>
</div>
<div id="appendix" class="section level2">
<h2>Appendix</h2>
<p>Code for the reactable table summarising Blueprint_DB:</p>
<pre class="r"><code>library(sparkline)
#-------------------
# Create Value_DB
#-------------------
# aggregation
tab_scan <- blueprint %>% select(DFU, Demand, Opening.Inventories, Supply.Plan,
Min.Stocks.Coverage,
Max.Stocks.Coverage) %>%
group_by(DFU) %>%
summarise(Total.Demand = sum(Demand),
Opening.Inventories = sum(Opening.Inventories),
Supply.Plan = sum(Supply.Plan),
Min.Stocks.Coverage = mean(Min.Stocks.Coverage),
Max.Stocks.Coverage = mean(Max.Stocks.Coverage)
)
# Get results
Value_DB <- tab_scan
#-------------------
# Create Sparklines for Demand
#-------------------
# replace missing values by zero
blueprint$Demand[is.na(blueprint$Demand)] <- 0
# aggregate
tab_scan <- blueprint %>%
group_by(DFU,
Period) %>%
summarise(Quantity = sum(Demand))
# generate Sparkline
Sparkline_Demand_DB <- tab_scan %>%
group_by(DFU) %>%
summarise(Demand.Quantity = list(Quantity))
#-------------------
# Create Sparklines for Supply Plan
#-------------------
# replace missing values by zero
blueprint$Supply.Plan[is.na(blueprint$Supply.Plan)] <- 0
# aggregate
tab_scan <- blueprint %>%
group_by(DFU,
Period) %>%
summarise(Quantity = sum(Supply.Plan))
# generate Sparkline
Sparkline_Supply_DB <- tab_scan %>%
group_by(DFU) %>%
summarise(Supply.Quantity = list(Quantity))
#----------------------------------------
# Link both databases
tab_scan <- left_join(Value_DB, Sparkline_Demand_DB)
tab_scan <- left_join(tab_scan, Sparkline_Supply_DB)
# Get Results
Overview_DB <- tab_scan
reactable(
tab_scan,
compact = TRUE,
defaultSortOrder = "asc",
defaultSorted = c("DFU"),
defaultPageSize = 20,
columns = list(
`DFU` = colDef(name = "Item", minWidth = 150),
`Opening.Inventories` = colDef(
name = "Opening Inventories (units)",
aggregate = "sum",
footer = function(values)
formatC(
sum(values),
format = "f",
big.mark = ",",
digits = 0
),
format = colFormat(separators = TRUE, digits = 0)
#style = list(background = "yellow",fontWeight = "bold")
),
`Total.Demand` = colDef(
name = "Total Demand (units)",
aggregate = "sum",
footer = function(values)
formatC(
sum(values),
format = "f",
big.mark = ",",
digits = 0
),
format = colFormat(separators = TRUE, digits = 0),
style = list(background = "yellow", fontWeight = "bold")
),
`Supply.Plan` = colDef(
name = "Supply Plan (units)",
aggregate = "sum",
footer = function(values)
formatC(
sum(values),
format = "f",
big.mark = ",",
digits = 0
),
format = colFormat(separators = TRUE, digits = 0)
),
`Min.Stocks.Coverage` = colDef(
name = "Min Stocks Coverage (periods)",
cell = data_bars(tab_scan,
#round_edges = TRUE
#value <- format(value, big.mark = ","),
#number_fmt = big.mark = ",",
fill_color = "#32CD32",
#fill_opacity = 0.8,
text_position = "outside-end")
),
`Max.Stocks.Coverage` = colDef(
name = "Max Stocks Coverage (periods)",
cell = data_bars(tab_scan,
#round_edges = TRUE
#value <- format(value, big.mark = ","),
#number_fmt = big.mark = ",",
fill_color = "#FFA500",
#fill_opacity = 0.8,
text_position = "outside-end")
),
Demand.Quantity = colDef(
name = "Demand",
cell = function(value, index) {
sparkline(tab_scan$Demand.Quantity[[index]])
}
),
Supply.Quantity = colDef(
name = "Supply",
cell = function(values) {
sparkline(values, type = "bar")
}
)
),
# close columns list
defaultColDef = colDef(footerStyle = list(fontWeight = "bold")),
columnGroups = list(
colGroup(
name = "Demand & Supply Inputs",
columns = c("Total.Demand", "Opening.Inventories", "Supply.Plan")
),
colGroup(
name = "Stocks Targets Parameters",
columns = c("Min.Stocks.Coverage", "Max.Stocks.Coverage")
)
)
) # close reactable</code></pre>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2022/11/21/projected-inventory-calculations-using-r-2/';</script>
September 2022: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2022/10/27/september-2022-top-40-new-cran-packages/
Thu, 27 Oct 2022 00:00:00 +0000https://rviews.rstudio.com/2022/10/27/september-2022-top-40-new-cran-packages/
<p>Two hundred and two new packages made it to CRAN in September. Here are my “Top 40” selections in fourteen categories: Computational Methods, Data, Genomics, Machine Learning, Mathematics, Medicine, Pharmacology, Psychology, Science, Social Science, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=kimfilter">kimfilter</a> v1.0.0: Provides an <code>Rcpp</code> implementation of the multivariate Kim filter, which combines the Kalman and Hamilton filters for state probability inference. The filter is designed for state space models and can handle missing values and exogenous data in the observation and state equations. See <a href="https://direct.mit.edu/books/book/3265/State-Space-Models-with-Regime-SwitchingClassical">Kim et al. (1999)</a> for details and the <a href="https://cran.r-project.org/web/packages/kimfilter/vignettes/kimfilter_vignette.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=SparseChol">SparseChol</a> v0.1.1: Provides a <code>C++</code> implementation of sparse LDL decomposition of symmetric matrices and solvers as described in <a href="https://fossies.org/linux/SuiteSparse/LDL/Doc/ldl_userguide.pdf">Davis (2016)</a>. See <a href="https://cran.r-project.org/web/packages/SparseChol/readme/README.html">README</a> for an example.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=allhomes">allhomes</a> v0.3.0: Provides tools to extract past sales data for specific suburbs and years from the <a href="https://www.allhomes.com.au/">Australian property</a> website including the address and property details, date, price, block size and unimproved value of properties. See <a href="https://cran.r-project.org/web/packages/allhomes/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=kgp">kgp</a> 1.1.0: Provides access to the metadata about populations and data about samples from the 1000 Genomes Project, including the 2,504 samples sequenced for the Phase 3 release and the expanded collection of 3,202 samples with 602 additional trios. The data is described in <a href="https://www.nature.com/articles/nature15393">Auton et al. (2015)</a> and <a href="https://www.cell.com/cell/fulltext/S0092-8674(22)00991-6?_returnURL=https%3A%2F%2Flinkinghub.elsevier.com%2Fretrieve%2Fpii%2FS0092867422009916%3Fshowall%3Dtrue">Byrska-Bishop et al. (2022)</a>, and raw data is available <a href="http://ftp.1000genomes.ebi.ac.uk/vol1/ftp/">here</a>. See <a href="https://arxiv.org/abs/2210.00539">Turner (2022)</a> for details and look <a href="https://stephenturner.github.io/kgp/">here</a> for examples.</p>
<p><img src="kgp.png" height = "300" width="500" alt="Map showing locations of 1000 Genomes Phase 3 populations"></p>
<p><a href="https://cran.r-project.org/package=eHDPrep">eHDPrep</a> v1.2.1: Provides a tool for the preparation and enrichment of health datasets for analysis including functions to assess data quality and enable semantic enrichment of a dataset by discovering metavariables from relationships among input variables determined from user-provided ontologies. See the <a href="https://cran.r-project.org/web/packages/eHDPrep/vignettes/Introduction_to_eHDPrep.pdf">vignette</a>.</p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=refdb">refdb</a> v0.1.1: Implements a reference database manager offering a set of functions to import, organize, clean, filter, audit and export reference genetic data and includes functions to download sequence data from <a href="https://www.boldsystems.org/">Bold Systems</a> and <a href="https://www.ncbi.nlm.nih.gov/genbank/">NCBI GenBank</a>. There is an <a href="https://cran.r-project.org/web/packages/refdb/vignettes/intro_refdb.html">Introduction</a> and a vignette on <a href="https://cran.r-project.org/web/packages/refdb/vignettes/ncbi_bold.html">Downloading and combining data</a>.</p>
<p><img src="refdb.png" height = "300" width="500" alt="Plot of taxonomic coverage"></p>
<p><a href="https://cran.r-project.org/package=RestoreNet">RestoreNet</a> v1.0: Implements a random-effects stochastic model that starts from an Ito-type equation describing the dynamics of cells duplication, death and differentiation at clonal level to detect clonal dominance events in gene therapy studies. See <a href="https://www.biorxiv.org/content/10.1101/2022.05.31.494100v1">Del Core et al., (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/RestoreNet/vignettes/RestoreNet.pdf">vignette</a> for the math and examples.</p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=DynForest">DynForest</a> v1.0.0: Implements a random forests model that uses multiple longitudinal predictors to make survival predictions for individual subjects. See <a href="https://arxiv.org/abs/2208.05801">Devaux et al.(2022)</a> for the details and the <a href="https://cran.r-project.org/web/packages/DynForest/vignettes/DynForest_surv.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=multiview">multiview</a> v0.4: Provides functions to fit cooperative learning models which are supervised learning models for multiple sets of features (“views”), as described in <a href="https://arxiv.org/abs/2112.12337">Ding et al. (2022)</a>. See the <a href="https://cran.r-project.org/web/packages/multiview/vignettes/multiview.pdf">vignette</a> for an introduction.</p>
<p><img src="multiview.png" height = "300" width="500" alt="Plot of model coefficients by L1 Norm for two different views"></p>
<p><a href="https://cran.r-project.org/package=survex">survex</a> v0.1.1: Implements methods for explaining survival models. Methods include <em>SurvSHAP(t)</em> as described in <a href="https://arxiv.org/abs/2208.11080">Krzyzinski et al. (2022)</a>, <em>SurvLIME</em> introduced in <a href="https://www.sciencedirect.com/science/article/abs/pii/S0950705120304044?via%3Dihub">Kovalev et al. (2020)</a>, as well as methods described in <a href="https://www.taylorfrancis.com/books/mono/10.1201/9780429027192/explanatory-model-analysis-przemyslaw-biecek-tomasz-burzykowski">Biecek et al. (2021)</a>. See the vignettes <a href="https://cran.r-project.org/web/packages/survex/vignettes/custom-explainers.html">Creating custom extensions</a> and <a href="https://cran.r-project.org/web/packages/survex/vignettes/survex-usage.html">Package usage</a>.</p>
<p><img src="survex.png" height = "400" width="400" alt="Brier Score and AUC plots"></p>
<p><a href="https://cran.r-project.org/package=voice">voice</a> v0.4.14: Provides general purpose tools for voice analysis, speaker recognition and mood inference. See the<a href="https://cran.r-project.org/web/packages/voice/vignettes/voicegnette_R.html">vignette</a> for an example.</p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=collatz">collatz</a> v1.0.0: Provides functions to explore the <a href="https://en.wikipedia.org/wiki/Collatz_conjecture">Collatz conjecture</a> including the ability to retrieve the hailstone sequence, the stopping time, total stopping time and tree-graph. There are four vignettes including: <a href="https://cran.r-project.org/web/packages/collatz/vignettes/collatz.html">collat</a>, <a href="https://cran.r-project.org/web/packages/collatz/vignettes/hailstones.html">Hailstone Sequences</a>, and <a href="https://cran.r-project.org/web/packages/collatz/vignettes/treegraphs.html">Tree Graphs</a>.</p>
<p><a href="https://cran.r-project.org/package=greta.dynamics">greta.dynamics</a> v0.2.0: Implements a <a href="https://joss.theoj.org/papers/10.21105/joss.01601"><code>greta</code></a> extension for analyzing transition matrices and ordinary differential equations representing dynamical systems. Have a look at the <a href="https://cran.r-project.org/web/packages/greta.dynamics/vignettes/iterate-matrix-example.html">iterate-matrix</a> and <a href="https://cran.r-project.org/web/packages/greta.dynamics/vignettes/ode-solve-example.html">ode-solve</a> examples.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=historicalborrow">historicalborrow</a> v1.0.4: Implements a hierarchical model and a mixture model to borrow historical control data from other studies to better characterize the control response a study. See <a href="https://onlinelibrary.wiley.com/doi/10.1002/pst.1589">Viele et al. (2013)</a> for a discussion of the methods and the vignettes <a href="https://cran.r-project.org/web/packages/historicalborrow/vignettes/methods.html">Methods</a> and <a href="https://cran.r-project.org/web/packages/historicalborrow/vignettes/usage.html">Usage</a>.</p>
<p><img src="historicalborrow.png" height = "300" width="500" alt="Plot of posterior response of borrow model against benchmark models for two arms of a trial."></p>
<p><a href="https://cran.r-project.org/package=nphRCT">nphRCT</a> v0.1.0: Provides functions to perform a stratified weighted log-rank test in a randomized controlled trial which can be visualized as a difference in average score on the two treatment arms. See <a href="https://arxiv.org/abs/1807.11097v1">Magirr and Burman (2018)</a>, <a href="https://arxiv.org/abs/2007.04767v1">Magirr (2020)</a>, and <a href="https://arxiv.org/abs/2201.10445v1">Magirr (2022)</a> for a description of the tests and the vignettes <a href="https://cran.r-project.org/web/packages/nphRCT/vignettes/explanation.html">Survival tests as differences-of-means</a> and <a href="https://cran.r-project.org/web/packages/nphRCT/vignettes/weighted_log_rank_tests.html]">The weighted log-rank test</a> for examples.</p>
<p><img src="nphRCT.png" height = "300" width="300" alt="Survival plots with Lof Rank Test Scores"></p>
<h3 id="pharmacology">Pharmacology</h3>
<p><a href="https://cran.r-project.org/package=rPBK">rPBK</a> v0.2.0: Provides functions to fit and simulate any kind of physiologically-based kinetic model which allows for multiple compartments, links between pairs of compartments, and links between compartments and the external medium. See <a href="https://www.biorxiv.org/content/10.1101/2022.04.29.490045v3">Charles et al. (2022)</a> for background and the <a href="https://cran.r-project.org/web/packages/rPBK/vignettes/Examples.html">vignette</a> for examples.</p>
<p><img src="rPBK.png" height = "300" width="300" alt="Concentration Plots"></p>
<p><a href="https://cran.r-project.org/package=xhaz">xhaz</a> v2.0.1: Provides functions to fit relative survival regression models with or without proportional excess hazards and with the additional possibility to correct for background mortality by one or more parameters. See <a href="https://journals.sagepub.com/doi/10.1177/0962280218823234">Touraine et al. (2020)</a>, <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-020-01139-z">Mba et al. (2020)</a>, and <a href="https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-019-0747-3">Goungounga et al. (2019)</a> for a description of the models and the <a href="https://cran.r-project.org/web/packages/xhaz/vignettes/introduction.html">vignette</a> for an introduction.</p>
<p><img src="xhaz.png" height = "400" width="400" alt="Survival plots for different models"></p>
<h3 id="psychology">Psychology</h3>
<p><a href="https://cran.r-project.org/package=rempsyc">rempsyc</a> v0.0.9: Provides convenience functions for Psychology including functions to customize plots and tables following the style of the American Psychological Association which are exportable to Microsoft Word. There are nine vignettes including <a href="https://cran.r-project.org/web/packages/rempsyc/vignettes/contrasts.html">Test linear regression assumptions</a>, <a href="https://cran.r-project.org/web/packages/rempsyc/vignettes/assumptions.html">Planned Contrasts Analyses</a>, and <a href="https://cran.r-project.org/web/packages/rempsyc/vignettes/scatter.html">Publication-ready scatter plots</a>.</p>
<p><img src="rempsyc.png" height = "500" width="500" alt="Formatted plots of regression tests"></p>
<h3 id="science">Science</h3>
<p><a href="https://cran.r-project.org/package=Karen">Karen</a> v1.0: Implements a stochastic framework that combines biochemical reaction networks with extended Kalman filter and Rauch-Tung-Striebel smoothing allowing biologists to investigate the dynamics of cell differentiation from high-dimensional clonal tracking data subject to measurement noise, false negative errors, and systematically unobserved cell types. See <a href="https://www.biorxiv.org/content/10.1101/2022.07.08.499353v1">Del Core et al. (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/Karen/vignettes/Karen.pdf">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=LMD">LMD</a> v1.0.0: Implements Local Mean Decomposition, an iterative and self-adaptive approach for demodulating, processing, and analyzing multi-component amplitude modulated and frequency modulated signals. See <a href="https://royalsocietypublishing.org/doi/10.1098/rsif.2005.0058">Smith (2005)</a> for background and the <a href="https://cran.r-project.org/web/packages/LMD/vignettes/Getting_Started_with_LMD.html">vignette</a> to get started.</p>
<p><img src="LMD.png" height = "300" width="500" alt="Plots of LMD decomposition of a simulated signal"></p>
<p><a href="https://cran.r-project.org/package=oceanexplorer">oceanexplorer</a> v0.0.2: Provides tools to explore the <a href="https://www.noaa.gov/">NOAA</a> <a href="https://www.ncei.noaa.gov/products/world-ocean-atlas">world ocean atlas</a> including functions to extract <a href="https://www.unidata.ucar.edu/software/netcdf/">NetCDF</a> data and visualize physical and chemical parameters. A <code>shiny</code> app allows interactive exploration. Look <a href="https://www.ncei.noaa.gov/products/world-ocean-atlas">here</a> for background information and see the <a href="https://cran.r-project.org/web/packages/oceanexplorer/vignettes/oceanexplorer.html">vignette</a> for examples.</p>
<p><img src="ocean.png" height = "300" width="500" alt="World map showing ocean PO4 levels"></p>
<p><a href="https://cran.r-project.org/package=WormTensor">WormTensor</a> v0.1.0: Implements a toolkit to detect clusters from distance matrices calculated between the cells of multiple animals (<a href="https://en.wikipedia.org/wiki/Caenorhabditis_elegans">Caenorhabditis elegans</a>) from input time-series matrices. Includes functions to generate, cluster, and visualize distance matrices, and to retrieve calculated distance matrices from <a href="https://figshare.com/">figshare</a>. See the <a href="https://cran.r-project.org/web/packages/WormTensor/vignettes/WormTensor.html">vignette</a>.</p>
<p><img src="WormTensor.png" height = "500" width="500" alt="Plot of cluster consistency colored by consistency"></p>
<h3 id="social-science">Social Science</h3>
<p><a href="https://cran.r-project.org/package=demcon">demcon</a> v0.3.0: Implements an open-source toolkit developed by <a href="https://www.isciences.com/">ISciences</a> and the <a href="https://www.dante-project.org/#:~:text=Previous%20Next-,The%20DANTE%20Project%20%2D%20open%20science%20tools%20to%20advance%20environment%2Dsecurity,political%20instability%2C%20and%20humanitarian%20response.">DANTE Project</a> for exploring popular political, institutional, and constitutional datasets with the goal of reducing barriers to entry in political science research by automating common acquisition and pre-processing procedures. This package focuses on the <a href="https://www.v-dem.net/vdemds.html">V-Dem dataset</a>. There are four vignettes including <a href="https://cran.r-project.org/web/packages/demcon/vignettes/constitution-datasets.html">A Brief Review of Constitutional Datasets</a> and <a href="https://cran.r-project.org/web/packages/demcon/vignettes/ccode-considerations.html">Country Coding Considerations for Dataset Harmonization</a>.</p>
<p><img src="demcon.png" height = "300" width="500" alt="Maps showing political boundaries of Yemen over time"></p>
<p><a href="https://cran.r-project.org/package=sdam">sdam</a> v1.1.4: Provides tools for performing social dynamics and complexity analyses about the Ancient Mediterranean in the context of the <a href="https://sdam-au.github.io/sdam-au/">SDAM</a> project based at the Department of History and Classical Studies at Aarhus University. There are vignettes on <a href="https://cran.r-project.org/web/packages/sdam/vignettes/Dates.html">Dates</a>, <a href="https://cran.r-project.org/web/packages/sdam/vignettes/Encoding.html">Re-encoding people</a>, <a href="https://cran.r-project.org/web/packages/sdam/vignettes/Intro.html">Datasets</a>, and <a href="https://cran.r-project.org/web/packages/sdam/vignettes/Maps.html">Maps and Networks</a>.</p>
<p><img src="sdam.png" height = "400" width="400" alt="Map showing the roads of the Roman Empire"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=adjustedCurves">adjustedCurves</a> v0.9.0: Provides functions to estimate and plot confounder-adjusted survival curves using either direct adjustment, inverse probability weighting, empirical likelihood estimation, or targeted maximum likelihood estimation. See <a href="https://arxiv.org/abs/2203.10002v1">Denz et. al (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/adjustedCurves/vignettes/introduction.html">vignette</a> for an introduction.</p>
<p><img src="adjustedCurves.png" height = "300" width="500" alt="Adjusted survival curves"></p>
<p><a href="https://cran.r-project.org/package=CovRegRF">CovRegRF</a> 1.0.1: Implements a method that uses <a href="https://cran.r-project.org/package=randomForestSRC">random forests</a> to estimate the covariance matrix of a multivariate response given a set of covariates as described in in <a href="https://cran.r-project.org/package=CovRegRF">Alakus et al. (2022)</a>. The <a href="https://cran.r-project.org/web/packages/CovRegRF/vignettes/CovRegRF.html">vignette</a> provides an example.</p>
<p><a href="https://cran.r-project.org/package=greta.gp">greta.gp</a> v0.2.0: Provides the syntax to create and combine full rank or sparse Gaussian process kernels in <code>greta</code>. See <a href="https://joss.theoj.org/papers/10.21105/joss.01601">Golding (2019)</a> for background on <code>greta</code> and the <a href="https://cran.r-project.org/web/packages/greta.gp/vignettes/getting-started.html">vignette</a> to get started.</p>
<p><img src="greta.png" height = "300" width="500" alt="Plot of posterior samples"></p>
<p><a href="https://cran.r-project.org/package=fwb">fwb</a> v0.1.1: Implements the fractional weighted bootstrap (aka the Bayesian bootstrap) to be used as a drop-in for functions in the <code>boot</code> package. The fractional weighted bootstrap involves drawing weights randomly that are applied to the data rather than resampling units from the data. See <a href="https://www.tandfonline.com/doi/abs/10.1080/00031305.2020.1731599?journalCode=utas20">Xu et al. (2020)</a> for the theory and <a href="https://cran.r-project.org/web/packages/fwb/readme/README.html">README</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=glmmrBase">glmmrBase</a> v0.1.2: Provides the R6 classes <code>Covariance</code>, <code>MeanFunction</code> and <code>Model</code> to allow for the flexible specification of generalized linear mixed models, and also functions to produce relevant matrices, values, and analyses. See <a href="https://cran.r-project.org/web/packages/glmmrBase/readme/README.html">README</a> for details.</p>
<p><a href="https://cran.r-project.org/package=rocbc">rocbc</a> v0.1.1: Provides functions for inferences and comparisons around the AUC, the Youden index, the sensitivity at a given specificity level, the optimal operating point of the ROC curve, and the Youden based cutoff. See <a href="https://onlinelibrary.wiley.com/doi/10.1002/bimj.201700107">Bantis et al. (2018)</a> and <a href="https://onlinelibrary.wiley.com/doi/10.1002/bimj.202000128">Bantis et al. (2021</a> and the <a href="https://onlinelibrary.wiley.com/doi/10.1002/bimj.202000128">vignette</a> for examples.</p>
<p><img src="rocbc.png" height = "400" width="400" alt="ROC curves"></p>
<p><a href="https://cran.r-project.org/package=vglmer">vglmer</a> v1.0.2: Provides functions to estimate hierarchical models using mean-field variational Bayes which can accommodate models with an arbitrary number of random effects and requires no integration to estimate. See <a href="https://projecteuclid.org/journals/bayesian-analysis/volume-17/issue-2/Fast-and-Accurate-Estimation-of-Non-Nested-Binomial-Hierarchical-Models/10.1214/21-BA1266.full">Goplerud (2022)</a> for details and <a href="https://cran.r-project.org/web/packages/vglmer/readme/README.html">README</a> for an example.</p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=bsvars">bsvars</a> v1.0.0: Implements MCMC algorithms for Bayesian estimation of Structural Vector Autoregressive (SVAR) models including a wide range of SVAR models. See <a href="https://www.sciencedirect.com/science/article/abs/pii/S0165188920300324?via%3Dihub"> Lütkepohl & Woźniak (2020)</a>, <a href="https://www.sciencedirect.com/science/article/abs/pii/S0165188902001689?via%3Dihub">Waggoner & Zha (2003)</a> for background.</p>
<p><a href="https://cran.r-project.org/package=gasmodel">gasmodel</a> v0.1.0: Provides functions to estimate, forecast and simulate generalized autoregressive score (GAS) models of <a href="https://onlinelibrary.wiley.com/doi/10.1002/jae.1279">Creal, Koopman, and Lucas (2013)</a> and <a href="https://www.cambridge.org/core/books/dynamic-models-for-volatility-and-heavy-tails/896F9D5220C4DD2CA675846F888F0BF0">Harvey (2013)</a>. There are two case study vignettes <a href="https://cran.r-project.org/web/packages/gasmodel/vignettes/case_durations.html">Bookshop Orders</a> and <a href="https://cran.r-project.org/web/packages/gasmodel/vignettes/case_rankings.html">Hockey Rankings</a> and another on <a href="https://cran.r-project.org/web/packages/gasmodel/vignettes/distributions.html">Probability Distributions</a>.</p>
<p><a href="https://cran.r-project.org/package=kalmanfilter">kalmanfilter</a> v2.0.0: Uses <code>Rcpp</code> to implement a multivariate Kalman filter for state space models that can handle missing values and exogenous data in the observation and state equations. See <a href="https://direct.mit.edu/books/book/3265/State-Space-Models-with-Regime-SwitchingClassical">Kim & Nelson (1999)</a> for details and the <a href="https://cran.r-project.org/web/packages/kalmanfilter/vignettes/kalmanfilter_vignette.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=MultiGlarmaVarSel">MultiGlarmaVarSel</a> v1.0: Provides functions to perform variable selection in high-dimensional sparse <a href="https://www.routledgehandbooks.com/doi/10.1201/b19485-5#:~:text=3.1%20Introduction,values%20of%20the%20observed%20process.">GLARMA models</a>. See <a href="https://arxiv.org/abs/2208.14721">Gomtsyan et al. (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/MultiGlarmaVarSel/vignettes/MultiGlarmaVarSel.pdf">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=VedicDateTime">VedicDateTime</a> v0.1.1: Provides functions to facilitate conversion between the Gregorian and Vedic calendar systems. See <a href="https://arxiv.org/abs/2111.03441">Bokde (2021)</a> and <a href="https:archive.org/details/PanchangamCalculations">Ramakumar (2011)</a> and the <a href="https://cran.r-project.org/web/packages/VedicDateTime/vignettes/VedicDateTime.pdf">vignette</a> for an overview with examples.</p>
<p><img src="Vedic.png" height = "500" width="300" alt= "tithi workflow"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=bundle">bundle</a> v0.1.0P Provides functions to serialize model objects with a consistent interface. See the <a href="https://cran.r-project.org/web/packages/bundle/vignettes/bundle.html">vignette</a> to get started.</p>
<p><img src="bundle.png" height = "300" width="500" alt= "Schematic of bundle serialization workflow"></p>
<p><a href="https://cran.r-project.org/package=r2resize">r2resize</a> v1.3: Implements an automatic resizing toolbar for containers, images and tables for <code>markdown</code>, <code>rmarkdown</code> and <code>quarto</code> documents. There is <a href="https://cran.r-project.org/web/packages/r2resize/vignettes/introduction_r2resize.html">Welcome</a> vignette and another on <a href="https://cran.r-project.org/web/packages/r2resize/vignettes/resizable_containers_split_screen_r2resize.html">New features</a>.</p>
<p><img src="r2resize.gif" height = "300" width="500" alt= "Schematic of bundle serialization workflow"></p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=figuRes2">figuRes2</a> v1.0.0: Provides functions and supporting documentation to streamline a variety of figure production tasks. There are vignettes on <a href="https://cran.r-project.org/web/packages/figuRes2/vignettes/basics.html">Basics</a>, <a href="https://cran.r-project.org/web/packages/figuRes2/vignettes/forest-plots.pdf">Forest plots</a>, <a href="https://cran.r-project.org/web/packages/figuRes2/vignettes/km.pdf">KM plots</a>, and <a href="https://cran.r-project.org/web/packages/figuRes2/vignettes/large-scale.pdf">Production Workflows</a>.</p>
<p><img src="figuRes2.png" height = "400" width="400" alt= "Scatter plot with marginal distributions"></p>
<p><a href="https://cran.r-project.org/package=openairmaps">openairmaps</a> v0.5.1: Combines <code>openair</code> air quality maps with <code>leaflet</code> to plot site maps with directional analysis figures such as polar plots, and air mass trajectories. See <a href="https://cran.r-project.org/web/packages/openairmaps/readme/README.html">README</a> for examples.</p>
<p><img src="openair.png" height = "300" width="500" alt= "Directional plots on map of London"></p>
<script>window.location.href='https://rviews.rstudio.com/2022/10/27/september-2022-top-40-new-cran-packages/';</script>
Using R in Inventory Management and Demand Forecasting
https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/
Thu, 20 Oct 2022 00:00:00 +0000https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/
<p><br>
<em>Nicolas Nguyen works in the Supply Chain industry, in the area of Demand and Supply Planning, S&OP and Analytics, where he enjoys developing solutions using R and Shiny. Outside his job, he teaches data visualization in R at the Engineering School EIGSI and Business School Excelia in the city of La Rochelle, France.</em></p>
<div id="introduction" class="section level2">
<h2>Introduction</h2>
<p>Demand & Supply Planning requires forecasting techniques to determine the inventory needed to fulfill future orders. With R, we can build end-to-end supply chain monitoring processes to identify potential issues and run scenario testing.</p>
<p>In a 3-part series, I will walk through a Demand & Supply Planning workflow:</p>
<ol style="list-style-type: decimal">
<li>Using R in Inventory Management and Demand Forecasting: an introduction of projected inventory and coverage methodology (this post)</li>
<li>Analyzing Projected Inventory Calculations Using R: an analysis of a demo dataset using the <code>planr</code> package</li>
<li>Visualizing Projected Calculations with <code>reactable</code> and <code>shiny</code>: once the analysis is done, how would you present your results to your boss?</li>
</ol>
<p>By the end of the series, you will understand how and why to use R for Demand & Supply Planning calculations. Let’s begin!</p>
</div>
<div id="the-problem-we-aim-to-solve" class="section level2">
<h2>The “problem” we aim to solve</h2>
<p>When we work in Demand & Supply Planning, it’s pretty common that we need to calculate <strong>projected inventories</strong> (and related <strong>projected coverages</strong>). We often have three options to perform this calculation, using:</p>
<ol style="list-style-type: decimal">
<li>an APS (Advanced Planning System) software</li>
<li>an ERP, such as SAP or JDE</li>
<li>and of course…Excel!</li>
</ol>
<p>All are fine and have different pros and cons. For example, we simply sometimes don’t have all the data in our ERP either APS, like when we work with third-party distributors or we want to model a supply chain network that relies on different systems with unconnected data.</p>
<p><strong>How about using R to perform these calculations?</strong> How simple and fast could they be? And, could we do more than just the calculations?</p>
<p>For example, could we get an analysis of the projected situation of a portfolio (as an output of a function), so we don’t have to look at each product one by one and can instead:</p>
<ul>
<li>Easily get a summary view of the portfolio?</li>
<li>Then zoom on the products with risks of shortages or overstocks?</li>
</ul>
<!-- I added this little intro paragraph about the series of posts -->
<p>In a series of posts, I will demonstrate how R can help us in Demand & Supply planning. This first post introduces the <code>proj_inv()</code> and <code>light_proj_inv()</code> functions for projected inventory and coverage calculations.</p>
<ul>
<li><code>proj_inv():</code> to calculate projected inventories and coverages with some analysis features</li>
<li><code>light_proj_inv():</code> to calculate projected inventories and coverages (only)
<ul>
<li>Runs faster than the previous function (as it’s lighter and doesn’t provide any analysis features)</li>
</ul></li>
</ul>
<p>With R, we have an efficient way to run end-to-end supply chain monitoring processes.</p>
</div>
<div id="methodology" class="section level2">
<h2>Methodology</h2>
<div id="how-to-calculate-projected-inventories" class="section level3">
<h3>How to calculate projected inventories</h3>
<p>First, let’s have a look at an example of how to calculate projected inventories. Consider that the field Demand = Sales Forecasts.</p>
<ol style="list-style-type: decimal">
<li>We start with some <strong>Opening Inventory</strong> of 1000 units.</li>
<li>During month M, we sell 100 units (the Demand). At the end of the 1st period (Month M), the inventory is 900 units.</li>
<li>Then, there’s a demand of 800 units at the end of the following period (Month M+1).</li>
<li>During the period (Month M+2), we get a Supply of 400 units, and sell 100: it is now 1100 units in stock.</li>
</ol>
<p>That’s all, this is how we calculate projected inventories ☺</p>
<p><img src="how%20to%20calculate%20a%20projected%20inventories.PNG" width="500" /></p>
<p><span class="smallcaps"><strong>Figure 1:</strong> Describes the mechanism of the calculation of projected inventories based on Opening Inventories, Demand and Supply</span></p>
</div>
<div id="how-to-calculate-projected-coverages" class="section level3">
<h3>How to calculate projected coverages</h3>
<p>Now, let’s have a look at how to calculate projected coverages. The idea: we look forward.</p>
<p>We consider the projected inventories at the end of a period and evaluate the related coverage based on the <strong>Upcoming Demand</strong>. See the example below:</p>
<p><img src="how%20to%20calculate%20projected%20coverages.PNG" width="600" /></p>
<p><span class="smallcaps"><strong>Figure 2:</strong> Description of the calculation of projected coverages, considering the inventories at a point in time and the Upcoming Demand</span></p>
<p>If we use Excel, we often see a “shortcut” to estimate the related coverages, like considering an average of the Demand over the next 3 or 6 months. This can lead to incorrect results if the Demand is not constant (if we have some seasonality or a strong trend, for example). <strong>However, these calculations become very easy through the <code>proj_inv()</code> and <code>light_proj_inv()</code> functions.</strong></p>
</div>
</div>
<div id="projected-inventory-calculations-in-r" class="section level2">
<h2>Projected inventory calculations in R</h2>
<p>Now, let’s see how the above is done using two functions from the <strong>planr package</strong>. First, let’s create a tibble of data for the example shown above (we will cover <code>Min.Stocks.Coverage</code> and <code>Max.Stocks.Coverage</code> more thoroughly in another post):</p>
<pre class="r"><code># Install the planr package
# remotes::install_github("nguyennico/planr")
library(planr)
library(dplyr)
Planr_Example <-
tibble::tribble(
~DFU, ~Period, ~Demand, ~Opening.Inventories, ~Supply.Plan, ~Min.Stocks.Coverage, ~Max.Stocks.Coverage,
"Item0001", "2022-01-01", 100L, 1000L, 0L, 0L, 0L,
"Item0001", "2022-02-01", 100L, 0L, 0L, 0L, 0L,
"Item0001", "2022-03-01", 100L, 0L, 400L, 0L, 0L,
"Item0001", "2022-04-01", 800L, 0L, 0L, 0L, 0L,
"Item0001", "2022-05-01", 100L, 0L, 0L, 0L, 0L,
"Item0001", "2022-06-01", 300L, 0L, 0L, 0L, 0L,
"Item0001", "2022-07-01", 100L, 0L, 400L, 0L, 0L
)</code></pre>
<p>Now apply the <code>proj_inv()</code> function:</p>
<pre class="r"><code>Calculated_Inv <- proj_inv(
data = Planr_Example,
DFU = DFU,
Period = Period,
Demand = Demand,
Opening.Inventories = Opening.Inventories,
Supply.Plan = Supply.Plan,
Min.Stocks.Coverage = Min.Stocks.Coverage,
Max.Stocks.Coverage = Max.Stocks.Coverage
)</code></pre>
<p>We can look at the output, which provides a lot of useful information including projected inventories and coverages:</p>
<pre class="r"><code>glimpse(Calculated_Inv)</code></pre>
<pre><code>## Rows: 7
## Columns: 14
## Groups: DFU [1]
## $ DFU <chr> "Item0001", "Item0001", "Item0001", "It…
## $ Period <chr> "2022-01-01", "2022-02-01", "2022-03-01…
## $ Demand <dbl> 100, 100, 100, 800, 100, 300, 100
## $ Opening.Inventories <int> 1000, 0, 0, 0, 0, 0, 0
## $ Calculated.Coverage.in.Periods <dbl> 2.9, 1.9, 2.7, 1.7, 0.7, 0.0, 99.0
## $ Projected.Inventories.Qty <dbl> 900, 800, 1100, 300, 200, -100, 200
## $ Supply.Plan <int> 0, 0, 400, 0, 0, 0, 400
## $ Min.Stocks.Coverage <int> 0, 0, 0, 0, 0, 0, 0
## $ Max.Stocks.Coverage <int> 0, 0, 0, 0, 0, 0, 0
## $ Safety.Stocks <dbl> 0, 0, 0, 0, 0, 0, NA
## $ Maximum.Stocks <dbl> 0, 0, 0, 0, 0, 0, NA
## $ PI.Index <chr> "OverStock", "OverStock", "OverStock", …
## $ Ratio.PI.vs.min <dbl> 0, 0, 0, 0, 0, 0, NA
## $ Ratio.PI.vs.Max <dbl> 0, 0, 0, 0, 0, 0, NA</code></pre>
<p>Focusing on the <code>Projected.Inventories.Qty</code> column, we see that it matches our example calculation in Figure 1.</p>
<pre class="r"><code>Calculated_Inv %>%
select(Projected.Inventories.Qty)</code></pre>
<pre><code>## # A tibble: 7 × 2
## # Groups: DFU [1]
## DFU Projected.Inventories.Qty
## <chr> <dbl>
## 1 Item0001 900
## 2 Item0001 800
## 3 Item0001 1100
## 4 Item0001 300
## 5 Item0001 200
## 6 Item0001 -100
## 7 Item0001 200</code></pre>
<p>We can also take a look at projected coverage. It matches our example calculation in Figure 2: the opening coverage is 2.9 months.</p>
<pre class="r"><code>Calculated_Inv %>%
select(Calculated.Coverage.in.Periods)</code></pre>
<pre><code>## # A tibble: 7 × 2
## # Groups: DFU [1]
## DFU Calculated.Coverage.in.Periods
## <chr> <dbl>
## 1 Item0001 2.9
## 2 Item0001 1.9
## 3 Item0001 2.7
## 4 Item0001 1.7
## 5 Item0001 0.7
## 6 Item0001 0
## 7 Item0001 99</code></pre>
<p>Very easy to calculate!</p>
<!-- I removed the examples of complex task and linked to the appendix -->
<p>The <code>proj_inv()</code> and <code>light_proj_inv()</code> functions can also be used and combined to perform more complex tasks. I’ve described several use cases in the <a href="#appendix">appendix</a>.</p>
<p>Moving forward, these functions form the basis for the classic <strong>DRP (Distribution Requirement Planning)</strong> calculation, where, based on some parameters (usually minimum and maximum levels of stock, a reorder quantity, and a frozen horizon), we calculate a Replenishment Plan.</p>
</div>
<div id="conclusion" class="section level2">
<h2>Conclusion</h2>
<p>Thank you for reading this introduction of projected inventories and coverages in Demand & Supply Planning! I hope that you enjoyed reading how this methodology translate into R.</p>
<div id="ascm-formerly-apics-guidelines" class="section level3">
<h3>ASCM (formerly APICS) guidelines</h3>
<p>In the beginning of 2019, the Association for Supply Chain Management (ASCM) published <a href="https://www.ascm.org/ascm-insights/sop-and-the-digital-supply-chain/">an article about the usage of R (and Python) in Supply Chain Planning</a>, and more precisely for the Sales & Operations Planning (S&OP) process, which is related to Demand and Supply Planning.</p>
<p><img src="make%20jump.PNG" width="600" /></p>
<p><span class="smallcaps"><strong>Figure 3:</strong> An extract from the ASCM article regarding the S&OP and Digital Supply Chain. It shows how R and Python are becoming more and more used for demand & supply planning and are great tools to run a S&OP process.</span></p>
<p>In the example above, we can see how R helps build the digital environment useful to run the S&OP process, which involves a lot of data processing. The <strong>planr package</strong> aims to support this process by providing functions that calculate projected inventories.</p>
</div>
<div id="stay-tuned-for-more-on-projected-calculations-using-r" class="section level3">
<h3>Stay tuned for more on projected calculations using R</h3>
<p>Thank you for reading the introduction on how to use R for projected inventory calculations in Demand & Supply Planning! I hope you enjoyed this introduction to the <strong>planr package</strong>.</p>
<p>My series of posts will continue with:</p>
<ul>
<li>Analyzing Projected Calculations Using R (using a demo dataset)</li>
<li>Visualizing Projected Calculations with reactable and Shiny (or, what your boss wants to see)</li>
</ul>
<p>In the meantime, check out these useful links:</p>
<ul>
<li>planr package GitHub repository: <a href="https://github.com/nguyennico/planr" class="uri">https://github.com/nguyennico/planr</a></li>
<li>URL for a Shiny app showing a demo of the <code>proj_inv()</code> and <code>light_proj_inv()</code> functions: <a href="https://niconguyen.shinyapps.io/Projected_Inventories/">Demo: app proj_inv() function (shinyapps.io)</a></li>
</ul>
<!-- Here is the appendix -->
</div>
</div>
<div id="appendix" class="section level2">
<h2>Appendix: Use cases and examples</h2>
<p>The <code>proj_inv()</code> and <code>light_proj_inv()</code> functions can easily be used and combined to perform more complex tasks, such as:</p>
<ul>
<li>Modeling of a Supply Chain Network</li>
<li>Calculation of projected inventories from Raw Materials to Finished Goods</li>
<li>A multi-echelon distribution network: from a National Distribution Center to Regional Wholesalers to Retailers</li>
</ul>
<p>Becoming a useful tool:</p>
<ul>
<li>To build an End-to-End Supply Chain monitoring process</li>
<li>To support the S&OP (Sales and Operations Planning) process, allowing us to run some scenarios quickly:
<ul>
<li>Change of Sales plan</li>
<li>Change of Supply (Production) plan</li>
<li>Change of stock level parameters</li>
<li>Change of Transit Time</li>
<li>Etc.</li>
</ul></li>
</ul>
<p>Here are some detailed use cases for the functions.</p>
<div id="third-party-distributors" class="section level3">
<h3>Third-party distributors</h3>
<p>We sometimes work with third-party distributors to distribute our products. A common question is: how much stock do our partners hold?</p>
<p>If we have access to their opening inventories and Sales IN & OUT Forecasts, we can quickly calculate the projected inventories by applying the <code>proj_inv()</code> or <code>light_proj_inv()</code> functions. Then, we anticipate any risks of shortages or overstocks, and create a collaborative workflow.</p>
<p><img src="sales%20IN%20sales%20OUT.PNG" width="500" /></p>
<p><span class="smallcaps"><strong>Figure 4:</strong> Illustration of a SiSo (Sales IN Sales OUT) situation. We have some stocks held at a storage location, for example, a third-party distributor, and know what will be sold out of this location (the sales out) and what will be replenished to it (the sales in), as well as the opening inventory. The aim is to calculate the projected inventories and coverages at this location.</span></p>
</div>
<div id="from-raw-materials-to-finished-goods" class="section level3">
<h3>From raw materials to finished goods</h3>
<p>In the example below, we produce olive oil (but it could be shampoo, liquor, etc.).</p>
<p>We start with a raw material, the olive oil, that we use to fill up different sizes of bottles (35cl, 50cl, etc…), on which we then apply (stick) a label (and back label). There are different labels, depending on the languages (markets where the products are sold).</p>
<p>Once we have a labelled bottle, we put it inside an outer box, ready to be shipped and sold. There are different dimensions of outer boxes, where we can put, for examplem 4, 6 or 12 bottles. <strong>They are the Finished Goods.</strong></p>
<p>We have two groups of products here:</p>
<ul>
<li>Finished Goods</li>
<li>Semi-Finished: at different steps, filled bottle (not yet labelled) or labelled bottle</li>
</ul>
<p>We might be interested in <strong>looking at the projected inventories at different levels / steps of the manufacturing process:</strong></p>
<ul>
<li>Finished Goods</li>
<li>Raw Materials: naked bottles, labels, or liquid (olive oil)</li>
<li>Semi-Finished Products</li>
</ul>
<p>For this, we can apply the <code>proj_inv()</code> or <code>light_proj_inv()</code> functions on each level of analysis.</p>
<p><img src="from%20raw%20materials%20to%20FG.PNG" width="600" /></p>
<p><span class="smallcaps"><strong>Figure 5:</strong> Illustration of a production flow, starting from raw material (liquid of olive oil) which fills bottles (of different countenances) and then labelled with different stickers. The labelled bottles are placed inside different outer boxes, which are the finished goods (called SKU -Stock Keeping Unit - ) .</span></p>
</div>
<div id="multi-echelon-networks" class="section level3">
<h3>Multi-echelon networks</h3>
<p>In the example below, we are looking at the distribution network within a country.</p>
<p>The products are stored at different locations:</p>
<ul>
<li>At a Central Stock: managed by the company selling the products, for example, a National Distribution Center.</li>
<li>At some third parties:
<ul>
<li>Who buy those products to distribute and sell them in more specific areas or regions</li>
<li>A network of Wholesalers and Sub-Wholesalers</li>
</ul></li>
</ul>
<p>If we have access to the data of the 3rd parties, such as [Opening Inventories] and [Sales IN & OUT Forecasts], we could apply the <code>proj_inv()</code> or <code>light_proj_inv()</code> functions on each level and visualize the complete projected inventories within the Distribution Network.</p>
<p><img src="multi%20echelons%20network.PNG" width="500" /></p>
<p><span class="smallcaps"><strong>Figure 6:</strong> Illustration of a distribution network, within a country, with different levels. The first level (level 1) is the main storage location, from which the products are shipped to the wholesalers (level 2), which then supply their local partners, identified here as Sub-Wholesalers (level 3). The aim is to visualize (and manage) the inventories (also Demand & Supply) throughout the whole network.</span></p>
</div>
<div id="from-production-capacity-to-sales" class="section level3">
<h3>From production capacity to sales</h3>
<p>In the example below, we have one or several Factories (within the box “Production Capacities”) which supply a [Global Stocks], which is then used to supply markets and a [Regional Stocks] directly. The [Regional Stocks] is then supplying other markets and a Third Party Distributor.</p>
<p><strong>We want to manage the Monthly S&OP process:</strong></p>
<ul>
<li>Linking Sales & Manufacturing Operations through simple modeling.</li>
<li>To balance Demand & Supply over the medium-long term horizon.</li>
<li>Visualizing some impacts through the whole distribution network</li>
</ul>
<p><strong>And make some simulations and drive some decisions:</strong></p>
<ul>
<li>Change of Sales Plan</li>
<li>Change of Supply Plan</li>
<li>Change of Inventories Level</li>
<li>Change of Transit Lead Time</li>
<li>Change of Product Mix</li>
<li>Etc.</li>
</ul>
<p>We could apply the <code>proj_inv()</code> or <code>light_proj_inv()</code> functions on each level and visualize the complete projected inventories within the Distribution Network.</p>
<p><img src="from%20production%20capacities%20to%20sales.PNG" width="500" /></p>
<p><span class="smallcaps"><strong>Figure 7:</strong> Illustration of a distribution network with a wider geographical presence. The first level (level 1) is the global storage location; it receives products from some factories and holds stocks that are used to supply several markets in the world, and also a regional stock, which is level 2. Then the regional stock is used to supply other markets, usually closer geographically, which is level 3. As described in the picture, the markets can be affiliates (where the stocks belong to the company) and third-party distributors.</span></p>
</div>
</div>
<script>window.location.href='https://rviews.rstudio.com/2022/10/20/projected-inventory-calculations-using-r-1/';</script>
Money, Money, Money: RConcillation
https://rviews.rstudio.com/2022/10/05/cash-flow-rconciliation/
Wed, 05 Oct 2022 00:00:00 +0000https://rviews.rstudio.com/2022/10/05/cash-flow-rconciliation/
<p><em>Dr. Maria Prokofieva is a member of the R / Business working group which is promoting the use of R in accounting, auditing, and actuarial work. She is also a professor at the Victoria University Business School in Australia and works with CPA Australia.</em></p>
<p>We continue with our series for “nerdy” accountants who want to diverge from Excel and master the power and beauty of R automation by looking at one of the most important areas of ANY business! Cash!</p>
<p>Cash management is a really critical issue for both business owners and people like me who are trying not to look at recent interest rates jumps.</p>
<p>Cash management includes cash collection, handling, and usage of cash (spending!). It is essential to have <strong>enough</strong> cash to cover immediate expenses, fund business growth and have working capital. Or in simple terms, you need to have enough cash to pay for your coffee, cover your mortgage repayment and invest in that <a href="https://www.tesla.com/en_au/model3">Tesla Model 3</a></p>
<p><img src="tesla.jpeg" height = "300" width="400" alt="Red Tesla Model 3"></p>
<p>Cash analysis is an important step to assess companies short-term liquidity, evaluate working capital and make decisions about investments.</p>
<p>Today, we are going to have a look at the step that comes before cash flow visualization. Much much earlier…. Before we are able to put cash flow items on a nice graph, we need to obtain those cash flow items “somehow”.</p>
<p>Accountants don’t have cash flow data by default, and there is no magic way to get it. Rather, it is necessary to go transaction by transaction, classify items, group them, collate them, and double-check that they actually occurred! We need to make sure that we are not double-charged as well as we are not underpaying or omitting any of our payments and they are all included in the list.</p>
<p>We start backwards from this very list and we dig into doing bank reconciliation and in particular, looking at our (business) bank statement. This is indeed a very useful exercise, not only in regards to your business but also for your own expense management.</p>
<p>For this post, we will work through a very simple example, just looking at a bank statement and poking around. It is a “personal” bank statement that comes from <a href="https://www.kaggle.com/datasets/sandhaya4u/august-bank-statement-sandhaya">Kaggle</a></p>
<pre class="r"><code>cf<-read_csv("bank_st.csv")</code></pre>
<pre><code>## Rows: 107 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): Date, Day, Type, Category
## dbl (3): Debit Amount, Credit Amount, Closing Balance
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.</code></pre>
<pre class="r"><code>cf%>%head()</code></pre>
<pre><code>## # A tibble: 6 × 7
## Date Day Type Category `Debit Amount` `Credit Amount` `Closing Balan…`
## <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
## 1 1/8/2018 Wedne… Debit Shopping 2500 0 174656.
## 2 1/8/2018 Wedne… Debit Shopping 324 0 174332.
## 3 2/8/2018 Thurs… None None 0 0 174332.
## 4 3/8/2018 Friday Debit Shopping 404. 0 173928.
## 5 4/8/2018 Satur… Debit Shopping 100 0 173828.
## 6 4/8/2018 Satur… Debit Shopping 1395 0 172433.</code></pre>
<p>This is a typical bank statement you can view in your bank account where each row is a transaction for a particular reporting period (e.g. month). We do not have the name of the second party for the transactions (e.g. the name of the store or the company that credited/debited the account), but all transactions have been classified - which can be seen under <code>Category</code>.</p>
<p>The dataset has <code>Debit Amount</code>, which is what you were charged, and <code>Credit Amount</code>, which is what you were paid. The <code>Closing Balance</code> is a running balance that shows the amount of cash in your account after the transaction. The most important parts of that <code>Closing Balance</code> are the initial and final numbers and they are used to reconcile (= match) balances in your own “books” (accounting books!= accounting records). If those number do not match, we investigate individual closing balances for the transactions to identify where we were overpaid or underpaid.</p>
<p>Let’s look closer at the data: it is not messy, but not ideal…</p>
<p>Column names have blanks and they do not play well in functions, so let’s use <code>clean_names()</code> from <code>janitor</code> package to make them more R friendly</p>
<pre class="r"><code>cf<-cf%>%
clean_names()
cf%>%head()</code></pre>
<pre><code>## # A tibble: 6 × 7
## date day type category debit_amount credit_amount closing_balance
## <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl>
## 1 1/8/2018 Wednesday Debit Shopping 2500 0 174656.
## 2 1/8/2018 Wednesday Debit Shopping 324 0 174332.
## 3 2/8/2018 Thursday None None 0 0 174332.
## 4 3/8/2018 Friday Debit Shopping 404. 0 173928.
## 5 4/8/2018 Saturday Debit Shopping 100 0 173828.
## 6 4/8/2018 Saturday Debit Shopping 1395 0 172433.</code></pre>
<p>That’s better! so now all variables are in small letters and have snake_case!</p>
<pre class="r"><code>names(cf)</code></pre>
<pre><code>## [1] "date" "day" "type" "category"
## [5] "debit_amount" "credit_amount" "closing_balance"</code></pre>
<p>Let’s explore the data and do some simple <strong>counting</strong> - yes, we love to count!</p>
<p>First, what is the closing balance and how does it change during the month? But before we do so, let’s have a close look at the <code>date</code> column. In the first twenty rows you can see there are a few issues as some dates include single vs. double for days and two-digit vs. four-digit for year. It is also in a string format.</p>
<pre class="r"><code>class(cf$date)</code></pre>
<pre><code>## [1] "character"</code></pre>
<pre class="r"><code>cf$date[1:20]</code></pre>
<pre><code>## [1] "1/8/2018" "1/8/2018" "2/8/2018" "3/8/2018" "4/8/2018" "4/8/2018"
## [7] "4/8/2018" "4/8/2018" "4/8/2018" "5/8/2018" "6/8/2018" "6/8/2018"
## [13] "7/8/2018" "8/8/2018" "9/8/2018" "10/8/2018" "10/8/2018" "11/8/2018"
## [19] "11/8/2018" "11/8/2018"</code></pre>
<p>To fix this, let’s convert to the date type and fix the formatting with <code>lubridate</code> package.</p>
<pre class="r"><code>cf$date<-dmy(cf$date)</code></pre>
<p>Now, let’s see the spend per each billing date. We exclude the days with no spend:</p>
<pre class="r"><code>cf%>%
group_by(date)%>%
summarise(spend=sum(debit_amount))%>%
filter(spend!=0)%>%
ggplot(aes(date, spend))+
geom_line()</code></pre>
<p><img src="/2022/10/05/cash-flow-rconciliation/index_files/figure-html/unnamed-chunk-7-1.png" width="672" /></p>
<p>Now, let’s see the type of categories we have.</p>
<pre class="r"><code>cf%>%count(category, sort=TRUE)</code></pre>
<pre><code>## # A tibble: 10 × 2
## category n
## <chr> <int>
## 1 Shopping 46
## 2 None 21
## 3 ATM 9
## 4 Interest 8
## 5 Entertainment 7
## 6 Medical 5
## 7 Travel 4
## 8 Restaurant 3
## 9 Rent 2
## 10 Salary 2</code></pre>
<p>This <code>None</code> category does not look right…. What is there?</p>
<pre class="r"><code>cf%>% filter(category=="None")%>%
head()</code></pre>
<pre><code>## # A tibble: 6 × 7
## date day type category debit_amount credit_amount closing_balance
## <date> <chr> <chr> <chr> <dbl> <dbl> <dbl>
## 1 2018-08-02 Thursday None None 0 0 174332.
## 2 2018-08-05 Sunday None None 0 0 162098.
## 3 2018-08-08 Wednesday None None 0 0 158597.
## 4 2018-08-21 Tuesday None None 0 0 91343.
## 5 2018-08-24 Friday None None 0 0 61755.
## 6 2018-08-26 Sunday None None 0 0 38441.</code></pre>
<p>It looks like the majority of these entries are not really transactions, but a closing balance. Do we need to include them? Probably not. Let’s confirm that they are not transactions and have <code>debit_amount</code> and <code>credit_amount</code> as zero</p>
<pre class="r"><code>cf%>% filter(category=="None")%>%
filter(debit_amount!=0 | credit_amount!=0)</code></pre>
<pre><code>## # A tibble: 0 × 7
## # … with 7 variables: date <date>, day <chr>, type <chr>, category <chr>,
## # debit_amount <dbl>, credit_amount <dbl>, closing_balance <dbl></code></pre>
<p>and it is a good idea to exclude them</p>
<pre class="r"><code>cf<-cf%>%filter(category!="None")</code></pre>
<p>Let’s see which day has the most number of transactions and which category is the most used one (what is the money drainer!):</p>
<pre class="r"><code>cf%>%count(day, sort=TRUE)</code></pre>
<pre><code>## # A tibble: 7 × 2
## day n
## <chr> <int>
## 1 Saturday 36
## 2 Friday 11
## 3 Thursday 10
## 4 Sunday 9
## 5 Wednesday 8
## 6 Monday 7
## 7 Tuesday 5</code></pre>
<pre class="r"><code>cf%>%count(category, sort=TRUE)</code></pre>
<pre><code>## # A tibble: 9 × 2
## category n
## <chr> <int>
## 1 Shopping 46
## 2 ATM 9
## 3 Interest 8
## 4 Entertainment 7
## 5 Medical 5
## 6 Travel 4
## 7 Restaurant 3
## 8 Rent 2
## 9 Salary 2</code></pre>
<p>Well, good, but does not look nice? So let’s “paint it”. (We look at spending where credited amount is $0 per category.)</p>
<pre class="r"><code>plot4<-cf%>%filter(credit_amount==0)%>%
group_by(day)%>%
summarise(day_spend=sum(debit_amount),
n=n())%>%
ggplot(aes(x=fct_reorder(day, desc(day_spend)),
y=day_spend))+
geom_col()+
labs(x = "Days", y = "$ value",
title ="Cash across days")+
theme(
panel.border = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.line = element_line(colour = "black"),
axis.text.x = element_text(angle = 90),
plot.title = element_textbox(hjust = 0.5,
width = unit(0.5, "npc"),
margin = margin(b = 15)) )
(plot1|plot2)/(plot3|plot4)</code></pre>
<p><img src="/2022/10/05/cash-flow-rconciliation/index_files/figure-html/unnamed-chunk-14-1.png" width="672" /></p>
<p>For a real business, this amount of Saturday transactions would raise a red flag, but this data is from personal records, so it looks like someone is having a blast after a busy week :)</p>
<p>Also, with <code>category</code> that <code>None</code> does not sound right…. it is the second highest so… I would really investigate what sort of <code>None</code> is that <code>None</code>…</p>
<p>Well, what are out total earn and which days we are paid and what for?</p>
<pre class="r"><code>cf%>%filter(credit_amount>0)%>%
count(category)</code></pre>
<pre><code>## # A tibble: 2 × 2
## category n
## <chr> <int>
## 1 Interest 8
## 2 Salary 2</code></pre>
<p>It looks like we have only two major category - interest and salary. Let’s see what brings more money</p>
<pre class="r"><code>cf%>%filter(credit_amount>0)%>%
group_by(category)%>%
summarise(category_total=sum(credit_amount))</code></pre>
<pre><code>## # A tibble: 2 × 2
## category category_total
## <chr> <dbl>
## 1 Interest 4050.
## 2 Salary 500508</code></pre>
<p>Well, it is still salary! but would be sooo good if it is our passive income that drives the cash flows!</p>
<p>Let’s see the balance for the month…</p>
<pre class="r"><code>balance<-sum(cf$credit_amount)-sum(cf$debit_amount)
balance</code></pre>
<pre><code>## [1] 268715</code></pre>
<p>Woohoo! Our balance is positive, so we managed to grow our wealth!</p>
<p>Indeed, it is a very simple example, but a good foundation to start your R experience in accounting!</p>
<p>Done for today: we are ready for bank RConciliation. Stay tuned!
….</p>
<div id="references" class="section level2">
<h2>References</h2>
<p><a href="https://www.kaggle.com/datasets/sandhaya4u/august-bank-statement-sandhaya" class="uri">https://www.kaggle.com/datasets/sandhaya4u/august-bank-statement-sandhaya</a></p>
</div>
<script>window.location.href='https://rviews.rstudio.com/2022/10/05/cash-flow-rconciliation/';</script>
August 2022: "Top 40" New CRAN Packages
https://rviews.rstudio.com/2022/09/26/august-2022-top-40-new-cran-packages/
Mon, 26 Sep 2022 00:00:00 +0000https://rviews.rstudio.com/2022/09/26/august-2022-top-40-new-cran-packages/
<p>One hundred ninety-four new package made it to CRAN in August. Here are my “Top 40” picks in thirteen categories: “Computational Methods, Data, Epidemiology, Genomics, Insurance, Machine Learning, Mathematics, Medicine, Pharmaceutical Applications, Statistics, Time Series, Utilities, and Visualization.</p>
<h3 id="computational-methods">Computational Methods</h3>
<p><a href="https://cran.r-project.org/package=brassica">brassica</a> v1.0.1: Executes <code>BASIC</code> programs from the 1970s for historical and educational purposes. This enables famous examples of early machine learning, artificial intelligence, natural language processing, cellular automata, and so on, to be run in their original form. See <a href="https://cran.r-project.org/web/packages/brassica/vignettes/BASIC.pdf">BASIC</a>.</p>
<p><a href="https://cran.r-project.org/package=MultiStatM">MultistatM</a> v1.1.0: Provides algorithms to build set partitions and commutator matrices used in the construction of multivariate d-variate Hermite polynomials. See the <a href="https://cran.r-project.org/web/packages/MultiStatM/vignettes/Introduction.html">vignette</a>.</p>
<h3 id="data">Data</h3>
<p><a href="https://cran.r-project.org/package=hubeau">hubeau</a> v0.3.1: functions to retrieve data from <a href="https://hubeau.eaufrance.fr/">Hub’Eau</a> the free and public French National APIs on water. See the <a href="https://cran.r-project.org/web/packages/hubeau/hubeau.pdf">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=tinytiger">tinytiger</a> v0.0.4: Download geographic shapes from the United States Census Bureau <a href="https://www.census.gov/geographies/mapping-files/time-series/geo/tiger-line-file.html">TIGER/Line Shapefiles</a>. See the <a href="https://cran.r-project.org/web/packages/tinytiger/vignettes/tinytiger.html">vignette</a>.</p>
<h3 id="epidemiology">Epidemiology</h3>
<p><a href="https://cran.r-project.org/package=disbayes">disbayes</a> v1.0.0: Provides functions to estimate incidence and case fatality for a chronic disease, given partial information, using a multi-state model. See <a href="https://arxiv.org/abs/2111.14100">Jackson et al. (2021)</a> for a description of the methods and the <a href="https://cran.r-project.org/web/packages/disbayes/vignettes/disbayes.html">vignette</a> for examples.</p>
<p><a href="https://cran.r-project.org/package=insectDisease">insectDiseases</a> v1.2.1: Provides the <a href="https://edwip.ecology.uga.edu/">Ecological Database of the Worlds Insect Pathogens</a> created by David Onstad. See the <a href="https://cran.r-project.org/web/packages/insectDisease/vignettes/dataManip.pdf">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=nncc">nncc</a> v1.0.0: Provides nearest-neighbors matching and analysis of case-control data. See <a href="https://journals.lww.com/epidem/Abstract/2022/09000/Nearest_Neighbors_Matching_for_Case_Control_Study.5.aspx">Cui et al. (2022)</a> for background and the <a href="https://cran.r-project.org/web/packages/nncc/vignettes/nncc.html">vignette</a> for examples.</p>
<p><img src="nncc.png" height = "300" width="500" alt="Distance density plot"></p>
<h3 id="genomics">Genomics</h3>
<p><a href="https://cran.r-project.org/package=epitopR">epitopR</a> v0.1.2: Offers a suite of tools to predict peptide MHC (major histocompatibility complex) presentation in the context of both human and mouse. Results are based on half maximal inhibitory concentration as queried through the <a href="http://tools.iedb.org/mhcii/">immune epitope database API</a>. See <a href="https://academic.oup.com/nar/article/47/D1/D339/5144151?login=false">Vita et al. (2018)</a> for background and the <a href="https://cran.r-project.org/web/packages/epitopR/vignettes/mhcII-hu.html">vignette</a> for an example.</p>
<p><a href="https://cran.r-project.org/package=geneHapR">geneHapR</a> v1.1.1: Provides functions to import genome variants data and perform gene haplotype Statistics, visualization and phenotype association. There is an <a href="https://cran.r-project.org/web/packages/geneHapR/vignettes/Introduction_of_geneHapR.html">Introduction</a>, and there are vignettes on <a href="https://cran.r-project.org/web/packages/geneHapR/vignettes/geneHapR_data.html">Data</a>, and <a href="https://cran.r-project.org/web/packages/geneHapR/vignettes/workflow.html">Workflow</a>.</p>
<p><img src="geneHapR.png" height = "300" width="500" alt="Workflow diagram"></p>
<p><a href="https://cran.r-project.org/package=genieBPC">geniePBC</a> v1.0.0: Linked to The American Association Research Project Genomics Evidence Neoplasia Information Exchange <a href="https://www.aacr.org/professionals/research/aacr-project-genie/the-aacr-project-genie-biopharma-collaborative-bpc/">(GENIE) BioPharma Collaborative</a>, this package provides an interface to the data corresponding to each release from <a href="https://www.synapse.org/">Synapse</a> and to prepare datasets for analysis. There are several vignettes including <a href="https://cran.r-project.org/web/packages/genieBPC/vignettes/drug_regimen_sunburst_vignette.html">drug regimen sunburst</a> and <a href="https://cran.r-project.org/web/packages/genieBPC/vignettes/pull_data_synapse_vignette.html">pull data synapse</a>.</p>
<p><img src="genieBPC.png" height = "300" width="500" alt="Sunburst plot showing 3 lines of treatment"></p>
<p><a href="https://cran.r-project.org/package=slendr">slendr</a> v0.3.0: Implements a framework for simulating spatially explicit genomic data which leverages real cartographic information for programmatic and visual encoding of spatiotemporal population dynamics on real geographic landscapes. Population genetic models are then automatically executed using a custom built-in simulation ‘SLiM’ script as described in <a href="https://academic.oup.com/mbe/article/36/3/632/5229931?login=false">Haller et al. (2019)</a>. There are several vignettes including <a href="https://cran.r-project.org/web/packages/slendr/vignettes/vignette-01-tutorial.html">A Basic Tutorial</a>, <a href="https://cran.r-project.org/web/packages/slendr/vignettes/vignette-03-interactions.html">Programming Dispersion Dynamics</a>, and <a href="https://cran.r-project.org/web/packages/slendr/vignettes/vignette-05-tree-sequences.html">Tree-sequence processing</a>.</p>
<p><img src="slendr.png" height = "300" width="500" alt="Network of ancestral links"></p>
<h3 id="insurance">Insurance</h3>
<p><a href="https://cran.r-project.org/package=actxps">actxps</a> v0.2.0: Supports actuarial experience studies with functions to prepare data, create studies and perform exposure calculations as described in: <a href="https://www.soa.org/49378a/globalassets/assets/files/research/experience-study-calculations.pdf">Atkinson & McGarry (2016)</a>. Look <a href="https://github.com/mattheaphy/actxps/">here</a> for an example.</p>
<p><img src="actxps.png" height = "300" width="500" alt="Shiny app for surrender experience study"></p>
<h3 id="machine-learning">Machine Learning</h3>
<p><a href="https://cran.r-project.org/package=aorsf">aorsf</a> v0.0.2: Provides functions to fit, interpret, and predict with oblique random survival forests. See <a href="https://arxiv.org/abs/2208.01129">Jaeger et al. (2022)</a> for methods to accelerate and interpret oblique random survival forest models. There is an <a href="https://cran.r-project.org/web/packages/aorsf/vignettes/aorsf.html">Introduction</a> and there are vignettes on <a href="https://cran.r-project.org/web/packages/aorsf/vignettes/oobag.html">Predictions</a> and <a href="https://cran.r-project.org/web/packages/aorsf/vignettes/pd.html">PD and ICE Curves</a>.</p>
<p><img src="aorsf.png" height = "300" width="500" alt="Risk ratio curve over time"></p>
<p><a href="https://cran.r-project.org/package=calibrationband">calibrationband</a> v0.2.1: Provides functions to assess the calibration of probabilistic classifiers using confidence bands for monotonic functions, and also facilitate constructing inverted goodness-of-fit tests whose rejection allows for a sought-after conclusion of a sufficiently well-calibrated model. See <a href="https://arxiv.org/abs/2203.04065">Dimitriadis et al. (2022)</a> for details and <a href="https://cran.r-project.org/web/packages/calibrationband/readme/README.html">README</a> for an example.</p>
<p><img src="cb.png" height = "500" width="500" alt="Plot of calibration curve vs. predicted probability"></p>
<p><a href="https://cran.r-project.org/package=kernelshap">kernelshap</a> v0.2.0: Multidimensional version of the iterative Kernel SHAP algorithm from game theory that has become popular for interpreting Machine Learning Models. <a href="http://proceedings.mlr.press/v130/covert21a">Covert & Lee (2021)</a> for details and <a href="https://cran.r-project.org/web/packages/kernelshap/readme/README.html">README</a> for an example.</p>
<p><img src="kernelshap.svg" height = "300" width="500" alt="Shap value plot for iris data set"></p>
<p><a href="https://cran.r-project.org/package=mlim">mlim</a> v0.0.9: Uses automated machine learning techniques to fine-tune a Elastic Net, Gradient Boosting, Random Forest, Deep Learning, Extreme Gradient Boosting, or Stacked Ensemble machine learning model for imputing the missing observations of each variable. See <a href="https://cran.r-project.org/web/packages/mlim/readme/README.html">README</a> for examples.</p>
<p><img src="mlim.png" height = "500" width="300" alt="mlim workflow"></p>
<p><a href="https://cran.r-project.org/package=tidytags">tidytags</a> v1.0.2: Facilitates the analysis of Twitter data by coordinates the simplicity of collecting tweets over time with a <a href="https://tags.hawksey.info/">Twitter Archiving Google Sheet</a> and the utility of the <a href="https://docs.ropensci.org/rtweet/"><code>rtweet</code></a> package for processing and preparing Twitter metadata. There is a <a href="https://cran.r-project.org/web/packages/tidytags/vignettes/setup.html">Getting Started Guide</a> and a vignette on using <a href="https://cran.r-project.org/web/packages/tidytags/vignettes/tidytags-with-conf-hashtags.html">conference hashtags</a>.</p>
<p><img src="tidytags.png" height = "500" width="400" alt="Network plot showing popularity of tweets"></p>
<h3 id="mathematics">Mathematics</h3>
<p><a href="https://cran.r-project.org/package=ambit">ambit</a> v0.1.2: Provides tools to simulate and estimate various types of <a href="https://link.springer.com/chapter/10.1007/978-3-642-18412-3_2">ambit processes</a>, including trawl processes and weighted <a href="https://link.springer.com/chapter/10.1007/978-3-319-94129-5_8">trawl processes</a>. There is a vignette on <a href="https://cran.r-project.org/web/packages/ambit/vignettes/vignette1_simulation.html">Simulating trawl processes</a> and another on estimating the <a href="https://cran.r-project.org/web/packages/ambit/vignettes/vignette2_trawlfct_estimation.html">Trawl function</a>.</p>
<p><img src="ambit.png" height = "400" width="500" alt="Plot of trawl process"></p>
<p><a href="https://cran.r-project.org/package=rTensor2">rTensor2</a> v0.1.1: Provides a set of tools for basic tensor operators including eigenvalue decomposition, the QR decomposition and LU decompositions, the inverse of a tensor, and the transpose of a symmetric tensor. (A tensor in this context is a multidimensional array.) See <a href="https://www.sciencedirect.com/science/article/pii/S0024379515004358">Kernfeld et al. (2015)</a> for background.</p>
<h3 id="medicine">Medicine</h3>
<p><a href="https://cran.r-project.org/package=RIbench">RIbench</a> v1.0.1: Provides a benchmark suite of tools for indirect methods of <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2556592/">reference interval</a> estimation. See the <a href="https://cran.r-project.org/web/packages/RIbench/vignettes/RIbench_package.html">vignette</a>.</p>
<p><img src="RIbench.png" height = "600" width="700" alt="Boxplots split by pathological fraction or sample size for a certain distribution type"></p>
<p><a href="https://cran.r-project.org/package=spiro">spiro</a> v0.1.1: Provides functions to import, process, summarize and visualize raw data from metabolic carts. See <a href="https://link.springer.com/article/10.2165/11319670-000000000-00000">Robergs, Dwyer, and Astorino (2010)</a> for details and the vignettes <a href="https://cran.r-project.org/web/packages/spiro/vignettes/import_processing.html">Importing & Processing</a> and <a href="https://cran.r-project.org/web/packages/spiro/vignettes/summarizing_plotting.html">Summarizing & Plotting</a>.</p>
<p><img src="spiro.png" height = "400" width="600" alt="Multiple plots from cardiopulmonary exercise testing"></p>
<h3 id="pharmaceutical-applications">Pharmaceutical Applications</h3>
<p><a href="https://cran.r-project.org/package=gtreg">gtreg</a> v0.1.1: Provides functions that leverage the <code>gtsummary</code> package to creates tables suitable for regulatory agency submissions. See the <a href="https://cran.r-project.org/web/packages/gtreg/vignettes/counting-methods.html">vignette</a> on adverse event counting methods.</p>
<p><a href="https://cran.r-project.org/package=tidyCDISC">tidyCDISC</a> v0.1.0: Implements a drag and drop <code>Shiny</code> application to allow users to construct [ADaM](<a href="https://www.cdisc.org/adam-course#:~:text=The%20Analysis%20Data%20Model%20(ADaM,wide%20variety%20of%20analysis%20methods.">https://www.cdisc.org/adam-course#:~:text=The%20Analysis%20Data%20Model%20(ADaM,wide%20variety%20of%20analysis%20methods.</a>) and <a href="https://www.cdisc.org">CDISC</a> compliant tables and plots for studying population and patient level data. See the <a href="https://cran.r-project.org/web/packages/tidyCDISC/vignettes/getting_started.html">vignette</a> for more information and look here to run a simulation.</p>
<p><img src="tidyCDISC.png" height = "400" width="600" alt="Data entry page for Shiny app"></p>
<h3 id="statistics">Statistics</h3>
<p><a href="https://cran.r-project.org/package=cassowaryr">cassowaryr</a> v2.0.0: Computes a range of scatterplot diagnostics (scagnostics) on pairs of numerical variables in a data set including the graph and association-based scagnostics described in <a href="https://www.tandfonline.com/doi/abs/10.1198/106186008X320465">Wilkinson & Graham (2008)</a> <a href="doi:10.1198/106186008X320465">doi:10.1198/106186008X320465</a> and the association-based scagnostics described by <a href="https://www.dr.hut-verlag.de/978-3-8439-3092-5.html">Grimm (2016)</a>. See the <a href="https://cran.r-project.org/web/packages/cassowaryr/vignettes/cassowaryr.html">vignette</a>.</p>
<p><img src="cassowaryr.png" height = "600" width="400" alt="Scagnostic plots"></p>
<p><a href="https://cran.r-project.org/package=contsurvplot">contsurvplot</a> v0.1.1: Provides tools to visualize the causal effect of a continuous variable on a time-to-event outcome including survival area plots, survival contour plots, survival quantile plots and 3D surface plots. See <a href="https://arxiv.org/abs/2208.04644v1">Denz & Timmesfeld (2022)</a> for details and the <a href="https://cran.r-project.org/web/packages/contsurvplot/vignettes/introduction.html">vignette</a> for examples.</p>
<p><img src="contsurvplot.png" height = "300" width="500" alt="Plot of survival area curves"></p>
<p><a href="https://cran.r-project.org/package=copre">copre</a> v0.1.0: Provides functions for Bayesian nonparametric density estimation using Martingale posterior distributions and includes the Copula Resampling (CopRe) algorithm, a Gibbs sampler for the marginal Mixture of Dirichlet Process (MDP) model, and an extension for full uncertainty quantification via a new Polya completion algorithm. See <a href="https://arxiv.org/abs/2206.08418">Moya & Walker (2022)</a>, <a href="https://arxiv.org/abs/2103.15671">Fong et al. (2021)</a>, and <a href="https://www.tandfonline.com/doi/abs/10.1080/01621459.1995.10476550">Escobar & West (1995)</a> for background and <a href="https://cran.r-project.org/web/packages/copre/readme/README.html">README</a> for an example .</p>
<p><img src="copre.png" height = "300" width="500" alt="Plot of mixture distributions"></p>
<p><a href="https://CRAN.R-project.org/package=InteractionPoweR">InteractionPoweR</a> v0.1.1: Provides functions for power analysis of regression models which tests the interaction of two independent variables on a single dependent variable. See the <a href="https://psyarxiv.com/5ptd7/">tutorial</a> and <a href="https://cran.r-project.org/web/packages/InteractionPoweR/readme/README.html">README</a> to get started.</p>
<p><a href="https://cran.r-project.org/package=singR">singR</a> v0.1.1: Implements the SING algorithm to extract joint and individual non-Gaussian components from two datasets. See <a href="https://projecteuclid.org/journals/annals-of-applied-statistics/volume-15/issue-3/Simultaneous-non-Gaussian-component-analysis-SING-for-data-integration-in/10.1214/21-AOAS1466.full">Risk & Gaynanova (2021)</a> for the theory and the <a href="https://cran.r-project.org/web/packages/singR/vignettes/singR-tutorial.html">vignette</a> for examples.</p>
<p><img src="singR.png" height = "400" width="600" alt="Multiple plots showing joint loadings"></p>
<p><a href="https://CRAN.R-project.org/package=SIRthresholded">SIRthresholded</a> v1.0.0: Implements a version of the <a href="https://en.wikipedia.org/wiki/Sliced_inverse_regression">Sliced Inverse Regression</a> method which may be used for variable selection. See the <a href="https://cran.r-project.org/web/packages/SIRthresholded/vignettes/SIRthresholded.html">vignette</a>.</p>
<p><img src="SIRthresh.png" height = "400" width="400" alt="Plots showing thresholded regularization paths"></p>
<p><a href="https://cran.r-project.org/package=sparseR">sparseR</a> v0.2.0: Implements ranked sparsity methods, including penalized regression methods such as the sparsity-ranked lasso, its non-convex alternatives, and elastic net, as well as the sparsity-ranked Bayesian Information Criterion. See <a href="https://link.springer.com/article/10.1007/s10182-021-00431-7">Peterson and Cavanaugh (2022)</a> for background and the <a href="https://cran.r-project.org/web/packages/sparseR/vignettes/sparseR.html">vignette</a> for an overview.</p>
<p><img src="sparseR.png" height = "300" width="500" alt="Plot of parameter estimate vs log of penalty"></p>
<p><a href="https://cran.r-project.org/package=spmodel">spmodel</a> v0.1.0:
Provides functions to fit, summarize, and predict a variety of spatial statistical models. Modeling features include anisotropy, random effects, partition factors and big data approaches. There is an <a href="https://cran.r-project.org/web/packages/spmodel/vignettes/basics.pdf">Overview</a>, a <a href="https://cran.r-project.org/web/packages/spmodel/vignettes/guide.pdf">Detailed Guide</a> and a vignette on <a href="https://cran.r-project.org/web/packages/spmodel/vignettes/technical.pdf">Technical Details</a>.</p>
<p><a href="https://cran.r-project.org/package=TRexSelector">TRexSelector</a> v0.0.1: Provides functions to perform fast variable selection in high-dimensional settings while controlling the false discovery rate at a user-defined target level. See <a href="https://arxiv.org/abs/2110.06048">Machkour et al. (2021)</a> for background and the <a href="https://cran.r-project.org/web/packages/TRexSelector/vignettes/TRexSelector_usage_and_simulations.htm">vignette</a> for an overview.</p>
<p><img src="TRex.png" height = "400" width="600" alt="Diagram of TRexSelector Framework"></p>
<p><a href="https://cran.r-project.org/package=VAJointSurv">VAJointSurv</a> v0.1.0: Provides functions to estimate joint marker (longitudinal) and survival (time-to-event) outcomes using variational approximations which allow for correlated error terms and multiple types of survival outcomes which may be left-truncated, right-censored, and recurrent. See the <a href="https://cran.r-project.org/web/packages/VAJointSurv/vignettes/VAJointSurv.html">vignette</a> for some theory and examples.</p>
<p><img src="VAJoint.png" height = "400" width="600" alt="Plots of estimated population means with pointwise confidence intervals"></p>
<h3 id="time-series">Time Series</h3>
<p><a href="https://cran.r-project.org/package=gmwmx">gmwmx</a> v1.0.2: Implements the Generalized Method of Wavelet Moments with Exogenous Inputs estimator (GMWMX) presented in <a href="https://arxiv.org/abs/2206.09668">Cucci et al. (2022)</a>. There are vignettes on <a href="https://cran.r-project.org/web/packages/gmwmx/vignettes/load_estimate_compare_models.html">Estimating and comparing models</a>, <a href="https://cran.r-project.org/web/packages/gmwmx/vignettes/remove_outliers_hector.html">Removing extreme values in time series</a>, <a href="https://cran.r-project.org/web/packages/gmwmx/vignettes/simulate_data.html">Generating data</a>, and <a href="https://cran.r-project.org/web/packages/gmwmx/vignettes/simulation_study.html">Simulation</a>.</p>
<p><img src="gmwmx.png" height = "300" width="500" alt="Plot of functional model of a time series"></p>
<h3 id="utilities">Utilities</h3>
<p><a href="https://cran.r-project.org/package=countdown">countdown</a> v0.4.0: Provides a simple countdown timer for slides and <code>HTML</code> documents written in <code>RMarkdown</code> or <code>Quarto</code> and with <code>Shiny</code>. See <a href="https://cran.r-project.org/web/packages/countdown/readme/README.html">README</a> for an example.</p>
<p><img src="countdown.gif" height = "300" width="500" alt="Countdown clock"></p>
<p><a href="https://cran.r-project.org/package=D4TAlink.light">D4TAlink.light</a> v2.2.9: Provides workload management tools to facilitate structuring R&D activities to comply with FAIR principles as discussed by <a href="https://direct.mit.edu/dint/article/2/1-2/10/10017/FAIR-Principles-Interpretations-and-Implementation">Jacobsen et al. (2017)</a> and with <a href="https://qscompliance.com/wp-content/uploads/2019/01/ALCOA-Principles.pdf">ALCOA+ principles</a> as proposed by the FDA. See the <a href="https://cran.r-project.org/web/packages/D4TAlink.light/vignettes/D4TAlink_basics.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=tinkr">tinkr</a> v0.1.0: Provides functions to convert <code>Markdown</code> and <code>RMarkdown</code> files to <code>XML</code> and back to allow their editing with <code>xml2</code> (XPath) instead of numerous complicated regular expressions. See the <a href="https://cran.r-project.org/web/packages/tinkr/vignettes/tinkr.html">vignette</a>.</p>
<p><a href="https://cran.r-project.org/package=typetracer">typetracer</a> v0.1.1: The <code>R</code> language includes a set of defined types, but has been described as being “absurdly dynamic” (<a href="https://dl.acm.org/doi/10.1145/3340670.3342426">Turcotte & Vitek (2019)</a>, and lacks tools to specify which types are expected by an expression. <code>typetracer</code>provides functions to extract detailed information on the properties of parameters passed to <code>R</code> functions. See the <a href="https://cran.r-project.org/web/packages/typetracer/vignettes/nse.html">vignette</a>.</p>
<h3 id="visualization">Visualization</h3>
<p><a href="https://cran.r-project.org/package=atime">atime</a> v2022.9.16: Provides functions for computing and visualizing <a href="https://en.wikipedia.org/wiki/Asymptotic_computational_complexity">comparative asymptotic timings</a> of different algorithms and code versions. Also includes functionality for comparing empirical timings with expected references such as linear or quadratic. There are several vignettes including <a href="https://cran.r-project.org/web/packages/atime/vignettes/git.html">Comparing git versions</a>, <a href="https://cran.r-project.org/web/packages/atime/vignettes/optseg.html">Optimal segmentation examples</a>, and <a href="https://cran.r-project.org/web/packages/atime/vignettes/regex.html">Regular Expression examples</a>.</p>
<p><img src="atime.png" height = "600" width="400" alt="Time comparison plots"></p>
<p><a href="https://cran.r-project.org/package=ggsurvfit">ggsurvfit</a> v0.1.0: Extends <code>ggplot2</code> to ease the creation of publication ready survival plots. See the vignettes <a href="https://cran.r-project.org/web/packages/ggsurvfit/vignettes/gallery.html">Gallery</a> and <a href="https://cran.r-project.org/web/packages/ggsurvfit/vignettes/themes.html">Themes</a>.</p>
<p><img src="ggsurvfit.png" height = "400" width="400" alt="Annotated Survival Plot"></p>
<p><a href="https://cran.r-project.org/package=oblicubes">oblicubes</a> v0.1.2: Extends the <a href="https://github.com/coolbutuseless/isocubes"><code>isocubes</code></a> package to provide three-dimensional rendering for <code>grid</code> and <code>ggplot2</code> graphics using cubes and cuboids drawn with an oblique projection. See the <a href="https://cran.r-project.org/web/packages/oblicubes/vignettes/oblicubes.html">vignette</a>.</p>
<p><img src="oblicubes.png" height = "400" width="400" alt="Textured rendering of 3D object with multiple holes"></p>
<p><a href="https://CRAN.R-project.org/package=ordr">ordr</a> v0.1.0: Provides a <code>tidyverse</code> extension for ordinations and biplots. Ordination comprises several multivariate techniques including principal components analysis which rely on eigen-decompositions or singular value decompositions of pre-processed numeric matrix data. The overlay of the resulting shared coordinates on a scatterplot is called a biplot. See <a href="https://link.springer.com/book/10.1007/1-4020-2236-0">Roux & Rouanet (2005)</a> for background. See the vignettes on <a href="https://cran.r-project.org/web/packages/ordr/vignettes/cmds-variables.html">Covariance Data</a> and <a href="https://cran.r-project.org/web/packages/ordr/vignettes/ordr.html">Ordination</a>.</p>
<p><img src="ordr.png" height = "500" width="500" alt="Example of a biplot"></p>
<script>window.location.href='https://rviews.rstudio.com/2022/09/26/august-2022-top-40-new-cran-packages/';</script>