I'm following the RStudio Guide to Document Templates to include a template within an R package. The example works through "Template Basics." But I get an error when I get to "Supporting Files" and I add create_dir: true to my template.yaml file, or when I add another file to the skeleton directory, both of which cause RStudio to prompt the user to specify a new directory in which to create the new file.
When I re-install the package and try to create a new RMarkdown file with my template, I get the error popup:
Couldn't create a template from C:/ ...[package directory]... at C:/ ...[desired output directory]... Error occurred while executing method
And in the RStudio console the error message is:
Error in (function (file, template, package = NULL, create_dir = "default", :
template.yaml must contain name and description fields
But the RStudio guide says nothing about a description field and I can't find an answer via Google on RMarkdown + YAML + "description." What's causing this?
I found the answer when examining the template.yaml files in the markdowntemplates package on GitHub. They specify a description in the YAML header, like this:
name: Kube Template
description: >
Kube template
create_dir: true
For the case of the RStudio tutorial linked above, adding this second line to my template.yaml got the example working:
name: My Template
description: My Template
Related
I am trying out Quarto, I am using R version 4.2.1. When I go to RStudio, File -> New File -> Quarto Document and create a new document, when I try to render via the RStudio Render button, I get the error 'C:/Program' is not recognized as an internal or external command, operable progam or batch file
I have tried installing R in a directory which has no white space in the installation path, but this did not resolve the issue.
UPDATE: on doing quarto check as suggested in comment gave me
Not sure what that means, but I was able to solve the problem by ensuring my qmd quarto file did not have white space in its name (replaced white space with underscores. The error then went away.
On changing my qmd file name, from HVL campaign.qmd to HVL_campaign.qmd (removing the white space), the rendering works. The error message was misleading though, that may need to get looked at...?
This error pops up if there is a space anywhere in the filepath unfortunately. I am running into this error when I try to make a new project in a directory that has a filepath with a space (thanks onderive...)
I am trying to knit together 3 files using this example: http://rmarkdown.rstudio.com/rmarkdown_websites.html
My files all share the same directory, which has been set in the RStudio build options. I literally copied the YML from the examples with my own file names. Even if I copy the examples directly, I get the same error.
I even ran the site_generator function from the RMarkdown Github: https://github.com/rstudio/rmarkdown/blob/master/R/render_site.R#L157
I noticed there are options for custom generators, which I do not want. All I would like to do is be able to knit together several markdown files into a single webpage and then create a navbar with tabs for each page/section.
I got the same error when attempting to build with an incorrectly named YAML config file. Specifically, the RStudio build option for a website requires that the config file be called _site.yml.
Verify that this file exists and that you're using the extension .yml rather than .yaml (even though the latter is preferred).
What helped for me was putting the line site: bookdown::bookdown_site back to index.Rmd.
lord, my issue was that i didn't set my working directly to where my _site.yml file and index.Rmd files are stored - the little things!
I fixed this error using this steps.
1-) RStudio-Tools-InstallPackages
2-) Install From should be CRAN Repository.
3-) write this command --> install.packages("install.packages("rmarkdown")")
4-) Click Install
And problem has gone... And this is output.
This error also appears when there is a format issue in the yaml section of index.Rmd.
In my case, I encountered the error when the opening "---" in index.Rmd had a couple of white spaces " ---".
If you are having this problem, I would recommend knitting index.Rmd by itself (not building the book) before trying anything more drastic.
I'm new to Roxygen and using Roxygen to document my functions and scripts (I'm not building a package, but using the package structure in order to be able to use Roxygen). I use Rd2HTML function to translate .Rd to .html. I'm trying to make a hyperlink in one .Rd file to another .Rd file, and maintain that link in the .html file.
Suppose I have two scripts and .Rd files: code1 and code2. When I add \code{\link{code1}} to the roxygen comments of code2, run roxygenize("<location of package>") and use Rd2HTML to built a html file, the result is that the html-file shows code1 instead of code1 at the location of \code{\link{code1}}. In other words: no hyperlink is shown in the html file of code1, instead code1 formatted as code is returned. Adding the package name does not resolve the issue.
Can anyone explain this behavior (and solve my issue :))?
Details:
NAMESPACE file:
# Generated by roxygen2 (4.1.1): do not edit by hand
export(code1)
export(code2)
DESCRIPTION file:
Package: Scripts
Type: Package
Title: What the package does (short line)
Version: 0.0.1
Date: 2012-11-12
Author: Who wrote it
Maintainer: Who to complain to <yourfault#somewhere.net>
Description: More about what it does (maybe more than one line)
License: GPL
I solved the issue myself. I hadn't installed the package and therefore couldn't locate any .html links.
By the way, http://yihui.name/en/2012/10/build-static-html-help/ helped me to easily build .html pages for help pages.
I am just starting to explore the rmarkdown package. I don't use Rstudio. I use the default R environment. What I did was as follows.
I created a new R document.
Started typing few lines in rmarkdown format.
Saved the file with Rmd extension.
I saved the file in the working directory.
I installed the pandoc using the pkg file.
I installed 'rmarkdown' package. Loaded the package.
Used the following command to render the Rmd file.
rmarkdown::render("Untitled.Rmd")
I get the following error.
Error in tools::file_path_as_absolute(input) : file 'Untitled.Rmd'
does not exist
I tried all the possible ways such as giving the exact path instead of filename etc. But nothing worked out. I googled the error message and found that none had similar error. Can someone help me with this. What I am missing. What the error message mean?
Most of the time the error file not found is either a type error or a real missing file (as in your case, the real one is named in another way).
In order to discard those possibilities:
Copy the fullpath from your filebrowser.
Make sure the file exists, inside R you could type:
file.exists("/fullpath/to/file")
If that return TRUE and the error persists, then you suspect another thing is going on.
I have a global ~/.Rprofile file and another .Rprofile file located in my project's current working directory and both of the have the following contents:
.First() <- function() {
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFile), "-s --webtex -o", shQuote(outputFile)))
}
)
}
Unfortunately, when I open the RStudio app neither of them appear to be working. The aim of what I'm trying to do is to make the "Knit HTML" button render the Markdown file, which has inline LaTeX, process through Pandoc using webtex as the LaTeX renderer.
Does anyone know how I check whether my .Rprofile files are loading at startup?
Thanks for any help!
POST ANSWER EDIT (after Josh's answer):
For clarity, my working project's .Rprofile file (which works) now reads as such:
options(rstudio.markdownHTML =
function(inputFile, outputFile) {
system(paste("pandoc", shQuote(inputFie), "-s --webtex -o", shQuote(outputFile)))
}
)
\\ you will need to end with a blank carriage return underneath
The R docs should help to see how to deal with .Rprofiles. Execute the following at the console:
> ?Startup
The relevant portion of this indicates that you need to put your project .Rprofile in the initial working directory that will be loaded when starting the project. Thus if your project is ~/foo/foobar.Rproj, then you should have your profile be ~/foo/.Rprofile and make sure that when starting up, the initial working directory is ~/foo/. You can see this in the title bar at the top of the console pane in RStudio.
Also to confirm that the correct .Rprofile is actually being loaded, I would personally put in a test to see which (if any) profile is being picked up. For example, include:
print("This is the Rprofile inside the foo project!")
Here is another example about getting this to work:
http://support.rstudio.org/help/discussions/suggestions/1095-different-rprofile-for-a-project#comment_15690293
Finally, if the correct .Rprofile is being loaded inside the project, then there must be something wrong with your code. Looks like you got this from our docs though, so if you get the profile loaded, and continue to have problems, please let us know. You can post a new discussion on our support thread.
Josh
Product Manager - RStudio