[R] "Impossible to run" error message when using Sweave

Douglas Bates bates at stat.wisc.edu
Wed Nov 17 16:12:59 CET 2004


Doran, Harold wrote:
> Dear List:
> 
> I have a large dataset of multiple schools. My goal is to produce a
> separate tex file for each school that plots some of the student
> achievement scores. Essentially, the aim is to develop a custom report
> for each school. To accomplish this, I have code for a loop that gets
> sourced into R and then Sweaves the multiple files to create the
> individual school reports.
> 
> Here is the code for the loop
> 
> schnum.list <- as.vector(unique(cmu$schid))
> 
> for(current.school in schnum.list) {
>     school.df <- subset(cmu, cmu$schid==current.school)
>     school.grades <- as.vector(unique(school.df$grade))
> 
>         sname <- paste(paste("read", current.school,
> sep=""),"Rnw",sep=".")
>         system(paste("schoolread.Rnw", paste("Reading/", sname, sep=""),
> sep=" "))
>         Sweave(file= paste("Reading/", sname, sep=""))
> }
> 
> 
> However, this begins to work and then produces the following errors
> 
> Writing to file read151-496-2982.tex
> Processing code chunks ...
> Error in file(con, "r") : unable to open connection
> In addition: Warning messages: 
> 1: Impossible to run 'G:\SWEAVE~1\SCHOOL~2.RNW
> Reading/read151-496-2982.Rnw 
> 2: cannot open file `Reading/read151-496-2982.Rnw' 
> 
> I'm not sure exactly what the impossible to run error is. I think this
> is on the verge of running correctly, but could use a little help.
> 
> Thanks,
> 
> Harold
> 
> Ver 1.9.0, Windows XP
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

It appears that you don't have the full path name for the input file 
correctly stated.  Rather than using paste to construct names, I would 
suggest using file.path.  You may also find it helpful to use getwd() to 
get the current working directory.




More information about the R-help mailing list