Thank you very much for your swift response. After deleting the extra bracket, the function worked, but something has changed in knitr's behaviour, now it does not produce the code for <<>>=@ in the .tex file (before below), but produces single line of r-like code (after below):
before making the suggested change:
\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{alltt}
\hlstd{lambda} \hlkwb{<-} \hlnum{5}
\hlstd{mu} \hlkwb{<-} \hlnum{60} \hlopt{/} \hlnum{7.5}
\hlstd{mu}
\end{alltt}
\begin{verbatim}
## [1] 8
\end{verbatim}
\end{kframe}
\end{knitrout}
after making the suggested change:
lambda <- 5mu <- 60 / 7.5mu## [1] 8
Error: You can't use `macro parameter character # in horizontal mode.
Moreover, it is still \usepackage[]{color} but not \usepackage[]{colour} that is being produced in the beginning of the .tex file after knitting the document after making the above-suggested change with the knit_hooks$set(). I removed knitr and installed again to produce previous behaviour.
Thank you for your time!