\documentclass{article}
\usepackage{biblatex}
\usepackage{amsmath}
%%\VignetteIndexEntry{entry name for CRAN}
%%\VignetteDepends{texor,rebib}

\abstract{
  Many of the early R packages used Sweave to write vigneettes,
  which will be shown to users as pdf format on CRAN. However, as
  time goes on, R Markdown, a lightweight markup language, has
  begun to gradually replace Sweave and better present content
  on CRAN in the form of HTML.

  In order to help many R package developers who haven't used R
  Markdown or don't have time to do the format conversion manually
  to migrate from Sweave to R Markdown, \code{texor} helps people
  automate this conversion process.
}

\begin{document}

\title{A Simple Example for rnw_to_rmd Function}
\author{Yinxiang Huang\\Beihang University\\\email{21375146@buaa.edu.cn}}

\section{Introduction to Sweave and Knitr}

Sweave options will be automatically converted to knitr.

\SweaveOpts{keep.source=TRUE, fig=TRUE}

To remove warning messages, setup code chunk use knitr option \texttt{warning=FALSE}.

<<setup,include=FALSE>>=
knitr::opts_chunk$set(warning = FALSE)
@

When the option OutDec is not \texttt{.}, put numbers in \texttt{\textbackslash{}text}.

<<>>=
options(OutDec = ',')
@

This is the first test. abc \Sexpr{0.6} def

another test $a = \Sexpr{0.6}$.

and the last one $a = \Sexpr{'0.6'}$.

<<>>=
options(OutDec = '.')
@

This is the second test. abc \Sexpr{0.6} def

another test $a = \Sexpr{0.6}$.

and the last one $a = \Sexpr{'0.6'}$.

Inline R code in verbatim environment will also be converted.

\begin{verbatim}
try this:
\Sexpr{1+1}
\end{verbatim}

\section{Generate Image from R Code Chunk}

The first image:

<<test, fig.cap="A fig o cars">>=
# Define the cars vector with 5 values
cars <- c(1, 3, 6, 4, 9)
plot(cars, type="o", col="blue")
title(main="Autos", col.main="red", font.main=4)
@

Insert a reference to the first image: \ref{fig:test}. And for bibtex\cite{Yinxiang:2024}.

Let's test another image from R code chunk:

<<image,fig=TRUE, fig.cap="matrix package's image">>=
if (system.file(package = "Matrix") == "") {
  install.packages("Matrix")
  library(Matrix)
} else {
  library(Matrix)
}
data(CAex, package = "Matrix")
print(image(CAex, main = "image(CAex)")) # print(.) needed for Sweave
@

Show R logo from file:

\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{Rlogo.png}
\caption{R logo}
\end{figure}

\bibliography{example}

\end{document}
