I would like to share the solution I found for the above error. (it took me a while, this is my first time posting on this forum).
The solution:
in yaml: use df_print: kable instead of df_print: paged
or
or create a new variable with the "head" statement inside the R chunks and then print with paste statement.
Below replicating the issue in the Rmarkdown document. Note df_print: paged causes head in r chunks to fail.
title: "Replicating Error"
output:
html_document:
df_print: paged
head(cars)