I am brand new to R and RMarkdown. I don't have any interest in actually using RStudio, I just want to run my RMarkdown commands on command line to generate PDF's. I have R, RStudio, and Mactex downloaded.I have the following file in my home directory:
DataAnalytics.Rmd
---
title: "Data Analytics in RMarkdown"
author: "Jennetta George"
output:
pdf_document: default
---
On the command line, I try running in my home directory
Rscript -e "rmarkdown::render('DataAnalytics.Rmd')"
which gives the error
zsh: no matches found: "rmarkdown::render('DataAnalytics.Rmd')"
or I try running
echo "rmarkdown::render('DataAnalytics.Rmd', clean=TRUE)" | R --slave
and get the error
Error in loadNamespace(name) : there is no package called ‘rmarkdown’
Calls: :: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
I have googled endlessly for a solution but there is not a lot out there on RMarkdown CLI. Would really appreciate some help troubleshooting this.
Fixed! In RStudio, I ran:
install.packages('knitr', dependencies = TRUE)
and
install.packages('markdown', dependencies = TRUE)
and now it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.