-
Notifications
You must be signed in to change notification settings - Fork 22
2 bugs in make.report #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,8 +40,30 @@ latex.figure <- function(figfile, reportfile, caption=''){ | |
| #' @return Nothing. | ||
| #' @export | ||
| make.report <- function(rep, reporttitle='', reportfile='report.tex', summaryoutfile='summaryout.txt', keep.figurefiles=FALSE, keep.txtfiles=FALSE, keep.texfiles=FALSE){ | ||
| if(basename(reportfile) == "") reportfile <- 'report.tex' | ||
| if(file.access(dirname(reportfile), mode=1) != 0) reportfile <- file.path(getwd(), reportfile) | ||
|
|
||
| # if file name specified | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are too many comments and not all of them say what the code does. E.g. here the code checks if "tex" is between dots in the |
||
| if("tex" %in% unlist(strsplit(basename(reportfile),"[.]"))){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test here could be: |
||
| # use filename | ||
| FileName <- basename(reportfile) | ||
| # if no path specified | ||
| if(file.access(dirname(reportfile), mode = 1) != 0 | dirname(reportfile) == "."){ | ||
| reportfile <- file.path(getwd(), FileName) | ||
| # if path exists | ||
| }else{ | ||
| reportfile <- file.path(dirname(reportfile), FileName) | ||
| } | ||
| }else{ | ||
| # if file name is empty - default file name | ||
| FileName <- "report.tex" | ||
| # if no path specified - getwd() | ||
| if(file.access(reportfile, mode = 1) != 0){ | ||
| reportfile <- file.path(getwd(), FileName) | ||
| # if path exists | ||
| }else{ | ||
| reportfile <- file.path(reportfile, FileName) | ||
| reportfile <- gsub(pattern = "//",replacement = "/",reportfile) | ||
| } | ||
| } | ||
|
|
||
| latexstart <- '\\documentclass[12pt]{article}\n\\usepackage{graphicx}\n\\usepackage{verbatim}\n\\begin{document}\n' | ||
| latexend <- '\\end{document}\n' | ||
|
|
@@ -101,8 +123,12 @@ make.report <- function(rep, reporttitle='', reportfile='report.tex', summaryout | |
|
|
||
| # -- Compile tex file -- # | ||
| #latexcompile <- system(paste('pdflatex -output-directory=../res/', reportfile), intern=TRUE) | ||
| latexcompile <- system(paste(paste0('pdflatex -output-directory=',file.path(dirname(reportfile))), file.path(reportfile)), intern=TRUE) | ||
| console_path1 <- gsub(x = file.path(dirname(reportfile)), pattern = " ", replacement = "\\\ ", fixed=TRUE) | ||
| console_path2 <- gsub(x = file.path(reportfile), pattern = " ", replacement = "\\\ ", fixed=TRUE) | ||
|
|
||
| latexcompile <- system(paste(paste0("pdflatex -output-directory=", console_path1), | ||
| console_path2), intern = TRUE) | ||
|
|
||
| # -- Remove temporary files -- # | ||
| #file.remove(paste0('../res/', substr(reportfile, 1, nchar(reportfile)-4), '.log')) | ||
| #file.remove(paste0('../res/', substr(reportfile, 1, nchar(reportfile)-4), '.aux')) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function returns
TRUEorinvisible(NULL)depending on!keep.figurefiles, not nothing! But maybe it should return something like the pdf filename with full path, so one could open it usingsystem(paste(getOption("pdfviewer"), outpdf), wait = FALSE). We can also have an argument to show the pdf file after creation.