exercises.R
library(tools)
Stangle("exercises.Rnw", output="exertest.R")
Sweave("exercises.Rnw", echo=F, eval=F, pdf=F, eps=F, output="exercises.tex")
Sweave("exercises.Rnw", echo=T, eval=T, pdf=T, eps=T, output='tmp.tex')
tmp = readLines('tmp.tex')
z = grep("dummy = ", tmp)
rep = gsub("dummy = \\\"", "\\\# ", tmp[z])
rep = gsub("\"", "", rep)
tmp[z] = rep
writeLines(tmp, "exersol.tex")
Stangle("exercises.Rnw", output="exertest.R")
Sweave("exercises.Rnw", echo=F, eval=F, pdf=F, eps=F, output="exercises.tex")
Sweave("exercises.Rnw", echo=T, eval=T, pdf=T, eps=T, output='tmp.tex')
tmp = readLines('tmp.tex')
z = grep("dummy = ", tmp)
rep = gsub("dummy = \\\"", "\\\# ", tmp[z])
rep = gsub("\"", "", rep)
tmp[z] = rep
writeLines(tmp, "exersol.tex")