Code works and I have updated R and LaTeX packages, reinstalled tinytex and added options(tinytex.verbose = TRUE) to get more information. Below is the error message.
output file: Lab-5-try.knit.md
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS Lab-5-try.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output Lab-5-try.tex --lua-filter "C:\Users\izzym\OneDrive\Documents\R\win-library\3.6\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\izzym\OneDrive\Documents\R\win-library\3.6\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in"
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/W32TeX) (preloaded format=pdflatex)
...rs\izzym\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...rs\izzym\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
I can't find the format file `pdflatex.fmt'!
Running the command C:\Users\izzym\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
kpathsea: Running mktexfmt pdflatex.fmt
The command name is C:\Users\izzym\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
I was unable to find any missing LaTeX packages from the error log Lab-5-try.log.
! ...rs\izzym\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:935: ...rs\izzym\AppData\Roaming\TinyTeX\bin\win32\runscript.tlu:858: no appropriate script or program found: fmtutil
! Running the command C:\Users\izzym\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! Running the command C:\Users\izzym\AppData\Roaming\TinyTeX\bin\win32\fmtutil-user.exe
! kpathsea: Running mktexfmt pdflatex.fmt
! The command name is C:\Users\izzym\AppData\Roaming\TinyTeX\bin\win32\mktexfmt
Error: LaTeX failed to compile Lab-5-try.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See Lab-5-try.log for more info.
Execution halted