\ SweaveInput {} error message missing files that are present

I have a Sweave file, JMP.Rnw, which injects several other files into the same directory. Relevant excerpt from JMP.Rnw (pulling into the prologue):

\SweaveInput{intro.tex} 

      

And yet, when I run Sweave from the command line, I get an error that the intro.tex could not be found.

> Sweave("JMP.Rnw")
Error in SweaveReadFile(c(ifile, file), syntax, encoding = encoding) : 
 no Sweave file with name ‘./intro.tex ’ found
> 

      

However, the file definitely exists:

$ find . -name intro.tex
./intro.tex
$ 

      

This input seems to work for other input files, but I cannot find a pattern that explains why some can be imported and others cannot. There seems to be a number of issues with Sweave and file encoding (see Sweave doesn't seem to have the right to encode .Rnw) , but that doesn't look like a problem here --- all files are us-ascii encoded:

$ file -bi JMP.Rnw
text/x-tex; charset=us-ascii
$ file -bi intro.tex
text/x-tex; charset=us-ascii
$ 

      

It's really weird that I have a separate Sweave paper setting and just move the intro.tex to that directory and add \ SweaveInput {intro.tex} to that main file works fine (ie builds without any problem). This other article uses a different LaTeX pattern, but this may seem out of place as I understand that Sweave basically ignores all of this until all blocks of code have been identified and executed (although my understanding here could be very wrong).

I am running R version 2.14.2 on an x86_64-pc-linux-gnu (64-bit) machine.

Update . While researching the answer from https://stackoverflow.com/users/210673/aaron , I found that in my additional article where \ SweaveInput {} actually works, the error message generated when trying to invoke a non-existent file does not contain extra space. those.

> Sweave("allocating_visibility.Rnw")
Error in SweaveReadFile(c(ifile, file), syntax, encoding = encoding) : 
 no Sweave file with name ‘./nothere.Rnw’ found
> 

      

Now I don't know why this trailing whitespace thing happens in one place but not another, but it seems like the most likely cause of the problem.

Update II . So, I think this is still an encoding problem. When I originally created the master.Rnw file, I pasted in some text that was utf-8 encoded. I converted the file back to ascii using http://billposer.org/Software/uni2ascii.html and still got a space error when I ran Sweave. However, when I removed the original \ SweaveInput {} line and retyped it, the problem was gone (ie, it was well-formed and the extra space in the error message was gone).

+3


source to share


1 answer


I think you might have \SweaveInput{intro.tex }

instead \SweaveInput{intro.tex}

since your error message has extra space in it before the quote ends.

To debug, you can also edit the command SweaveReadFile

in the package utils

to output the name of the files it is looking for, eg.



SweaveReadFileNew <- function(file, syntax, encoding = "") {
  message(gettextf("looking for Sweave file with name %s", sQuote(file[1L])), domain = NA)
  SweaveReadFileOrig(file, syntax, encoding)
}
SweaveReadFileOrig <- utils:::SweaveReadFile
assignInNamespace("SweaveReadFile", SweaveReadFileNew, ns="utils")

      

+3


source







All Articles