Decision models can synthesize evidence from different sources to provide estimates of long-term consequences of a decision with uncertainty. Cohort state-transition models (cSTM) are decision models commonly used in medical decision making because they can simulate hypothetical cohorts' transitions across various health states over time. This tutorial shows how to conceptualize cSTMs in a programming language environment and shows examples of their implementation in R. We illustrate their use in a cost-effectiveness analysis of a treatment using a previously published testbed cSTM. Both time-independent cSTM where transition probabilities are constant over time and time-dependent cSTM where transition probabilities vary over time are represented. For the time-dependent cSTM, we consider transition probabilities dependent on age and state residence. We also illustrate how this setup can facilitate the computation of epidemiological outcomes of interest, such as survival and prevalence. We conclude by demonstrating how to calculate economic outcomes and conducting a cost-effectiveness analysis of a treatment compared to usual care using the testbed model. We provide a link to a public repository with all the R code described in this tutorial that can be used to replicate the example or to be modified to suit different decision modeling needs.