This paper introduces the R package *sandwich*, which provides a unified framework for implementing heteroskedasticity-consistent (HC) and heteroskedasticity and autocorrelation consistent (HAC) covariance matrix estimators. These estimators are essential for econometric models that exhibit autocorrelation and/or heteroskedasticity, which are common in economic data. The package includes functions for various HC and HAC estimators, such as HC0, HC1, HC2, HC3, HC4, and HAC estimators based on kernel functions. The functions are designed to be flexible and easy to use, allowing users to specify the type of estimator and the weights used. The paper also demonstrates how these estimators can be integrated into inferential procedures, such as partial $t$ or $z$ tests, and provides real-world examples to illustrate their application. The *sandwich* package is implemented in the R system, which is widely used in econometrics, and is available under the GNU General Public License (GPL) from CRAN. The paper concludes by summarizing the key features of the package and its potential applications in econometric computing.This paper introduces the R package *sandwich*, which provides a unified framework for implementing heteroskedasticity-consistent (HC) and heteroskedasticity and autocorrelation consistent (HAC) covariance matrix estimators. These estimators are essential for econometric models that exhibit autocorrelation and/or heteroskedasticity, which are common in economic data. The package includes functions for various HC and HAC estimators, such as HC0, HC1, HC2, HC3, HC4, and HAC estimators based on kernel functions. The functions are designed to be flexible and easy to use, allowing users to specify the type of estimator and the weights used. The paper also demonstrates how these estimators can be integrated into inferential procedures, such as partial $t$ or $z$ tests, and provides real-world examples to illustrate their application. The *sandwich* package is implemented in the R system, which is widely used in econometrics, and is available under the GNU General Public License (GPL) from CRAN. The paper concludes by summarizing the key features of the package and its potential applications in econometric computing.