forked from Sharpie/RTikZDevice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First cut outputting directly to R objects
- If the `raw` option is true then output is directed to the object specified by the `object` argument to tikz(). - The object is created temporarily in the .tikzInternal environment then is copied to the calling environment when dev.off() is called. - When the object is copied it is created in the calling environment as an object of class 'tikz' - There is a print.tikz() function that will by default direct output to the original `file` specified in tikz() - Much more error checking is needed - The method for storing output in the .tikzInternal environment should be refined, possibly to save multiple sets of output and recall them later - Things feel a bit kludgy right now, lots of room for spiffing up
- Loading branch information
1 parent
b037425
commit 0a59d32
Showing
5 changed files
with
187 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' Print tikzDevice output to a file or the screen | ||
#' This function will print the TikZ code contained in an object of class | ||
#' 'tikz' either to a file or to the screen. | ||
#' | ||
#' This function should be used with the \code{raw} option to \code{tikz()}. The | ||
#' default is to simply print the TikZ code to the file originally specified | ||
#' in the call to \code{tikz()}, reproducing the default behavior. | ||
#' | ||
#' @param x An object of class 'tikz' | ||
#' @param filename The file to output TikZ code to | ||
#' @param raw If \code{TRUE}, print the raw TikZ code to the screen. | ||
#' | ||
#' | ||
#' @return Nothing is returned | ||
#' | ||
#' @author Cameron Bracken \email{cameron.bracken@@gmail.com} | ||
#' | ||
#' @seealso \code{\link{tikz}} | ||
#' @keywords character | ||
#' | ||
#' @examples | ||
#' tikz(raw=TRUE,object='p') | ||
#' plot(1) | ||
#' dev.off() | ||
#' print(p) | ||
#' | ||
#' @export | ||
print.tikz <- function(x, filename = x$filename, raw = FALSE){ | ||
|
||
if(raw){ | ||
cat(x) | ||
}else{ | ||
cat('Writing TikZ output to:', filename, '\n') | ||
cat(x$lines,file = filename) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters