Yes, I think that is the implication. The basic desire is to be able to store the output in a variable (which might possibly be manipulated) and then print it out or embed it in a file later.<br><br><div class="gmail_quote">
On Sun, Dec 6, 2009 at 3:47 PM, Cameron Bracken <span dir="ltr"><<a href="mailto:cameron.bracken@gmail.com">cameron.bracken@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Now if you call tikz with an empty file name<br>
<br>
tikz('')<br>
<br>
it will dump to the console. It cant be called with no file name<br>
because that will default to the standard Rplots.tex file. The changes<br>
are on Github.<br>
<br>
As for the rawConnection functionality, I do not know much about this<br>
sort of R programming but I suppose it would be possible. Am I right<br>
in thinking that afterward you might then<br>
<br>
print(rc)<br>
<br>
to output to a file? It would certainly not be trivial on the C level<br>
but I believe it could be done.<br>
<br>
-Cameron<br>
<br>
<br>
<br>
On Sun, Dec 6, 2009 at 1:28 PM, Gabor Grothendieck<br>
<div><div></div><div class="h5"><<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>> wrote:<br>
> img.raw is intended to represent the name of a raw R object, not a file<br>
> name.<br>
><br>
> On Sun, Dec 6, 2009 at 3:25 PM, Gabor Grothendieck <<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>><br>
> wrote:<br>
>><br>
>> And yet another comment. There has been a recent discussion about<br>
>> allowing devices to output to connections on r-devel and apparently this has<br>
>> languished for years despite Jeffrey Horner posting code which would have<br>
>> allowed it 3 years ago. Would it be a problem for tikz to handle that even<br>
>> if the other devices don't? For example, Hadley Wickham had posted this<br>
>> proposed functionality:<br>
>><br>
>> rc <- rawConnection("raw.img", "w")<br>
>> png(rc)<br>
>> plot(1:10)<br>
>> dev.off()<br>
>> close(rc)<br>
>><br>
>> where in this case png() would be replaced with tikz().<br>
>><br>
>> On Sun, Dec 6, 2009 at 3:17 PM, Gabor Grothendieck<br>
>> <<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>> wrote:<br>
>>><br>
>>> Great. Just one other related comment. I think I would likely use the<br>
>>> tikz(..., append=TRUE) style but some might prefer to use sink. That could<br>
>>> be done if it were possible to write the output to stdout like this. If<br>
>>> its not a problem you might want to add that too.<br>
>>><br>
>>> sink("myfile.tex")<br>
>>> cat("\\documentclass{article}<br>
>>> \\usepackage{tikz}<br>
>>> \begin{document}<br>
>>> \\begin{figure}[ht]<br>
>>> \\centering<br>
>>> ")<br>
>>> # "" or "stdout" or default writes to stdout<br>
>>> tikz(width=5, height=5)<br>
>>> x <- rnorm(100)<br>
>>> plot(x)<br>
>>> dev.off()<br>
>>> cat("\\caption{caption}<br>
>>> \\label{fig:inline}<br>
>>> \\end{figure}<br>
>>> \\end{document}<br>
>>> ")<br>
>>> sink()<br>
>>><br>
>>><br>
>>><br>
>>> On Sun, Dec 6, 2009 at 3:04 PM, Cameron Bracken<br>
>>> <<a href="mailto:cameron.bracken@gmail.com">cameron.bracken@gmail.com</a>> wrote:<br>
>>>><br>
>>>> I liked this idea so much that I implemented it right away. You can<br>
>>>> get it from the master branch of my github fork until the next release<br>
>>>><br>
>>>> <a href="http://github.com/cameronbracken/rtikzdevice/network" target="_blank">http://github.com/cameronbracken/rtikzdevice/network</a><br>
>>>><br>
>>>> Instead of "append" i called it "console." It works nearly as you<br>
>>>> envisioned:<br>
>>>><br>
>>>> cat("\\documentclass{article}<br>
>>>> \\usepackage{tikz}<br>
>>>><br>
>>>> \\begin{document}<br>
>>>> \\begin{figure}[ht]<br>
>>>> \\centering<br>
>>>> ", file = "myfile.tex")<br>
>>>><br>
>>>> sink("myfile.tex",append=T)<br>
>>>> tikz(console=T, width=5, height=5)<br>
>>>><br>
>>>> x <- rnorm(100)<br>
>>>> plot(x)<br>
>>>> quiet <- dev.off()<br>
>>>> sink()<br>
>>>><br>
>>>> cat("\\caption{caption}<br>
>>>><br>
>>>> \\label{fig:inline}<br>
>>>> \\end{figure}<br>
>>>> \\end{document}<br>
>>>> ", file = "myfile.tex", append = TRUE)<br>
>>>><br>
>>>> The following will now produce a self contained tex file:<br>
>>>><br>
>>>> \documentclass{article}<br>
>>>> \usepackage{tikz}<br>
>>>> \usepackage[nogin]{Sweave}<br>
>>>> \begin{document}<br>
>>>> \begin{figure}[ht]<br>
>>>> \centering<br>
>>>> <<inline,echo=F,results=tex>>=<br>
>>>><br>
>>>> require(tikzDevice)<br>
>>>> tikz(console=T,width=5,height=5)<br>
>>>> x <- rnorm(100)<br>
>>>> plot(x)<br>
>>>> dummy <- dev.off()<br>
>>>><br>
>>>> @<br>
>>>> \caption{caption}<br>
>>>> \label{fig:inline}<br>
>>>> \end{figure}<br>
>>>> \end{document}<br>
>>>><br>
>>>><br>
>>>> -Cameron<br>
>>>><br>
>>>><br>
>>>> On Sun, Dec 6, 2009 at 9:46 AM, Gabor Grothendieck<br>
>>>> <<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>> wrote:<br>
>>>> > If you able to provide this feature (i.e. incorporate the tikz tex<br>
>>>> > directly<br>
>>>> > into the current file rather than writing out a temporary file and<br>
>>>> > reading<br>
>>>> > it back in) then that would be useful since one of the key potential<br>
>>>> > advantages of tikz and pgf are the ability to have a single file<br>
>>>> > rather than<br>
>>>> > multiple files. Perhaps an append=TRUE argument like this:<br>
>>>> ><br>
>>>> > cat("\\documentclass{article}<br>
>>>> > \\usepackage{tikz}<br>
>>>> > \begin{document}<br>
>>>> > \\begin{figure}[ht]<br>
>>>> > \\centering<br>
>>>> > ", file = "myfile.tex")<br>
>>>> > tikz("myfile.tex", width=5, height=5, append = TRUE)<br>
>>>> > x <- rnorm(100)<br>
>>>> > plot(x)<br>
>>>> > dev.off()<br>
>>>> > cat("\\caption{caption}<br>
>>>> > \\label{fig:inline}<br>
>>>> > \\end{figure}<br>
>>>> > \\end{document}<br>
>>>> > ", file = "myfile.tex", append = TRUE)<br>
>>>> ><br>
>>>> > On Sun, Dec 6, 2009 at 11:34 AM, Cameron Bracken<br>
>>>> > <<a href="mailto:cameron.bracken@gmail.com">cameron.bracken@gmail.com</a>><br>
>>>> > wrote:<br>
>>>> >><br>
>>>> >> Interesting Idea. This should work with plain Sweave. It is not<br>
>>>> >> very<br>
>>>> >> efficient and would be very slow for large files since it must write<br>
>>>> >> out then read in then write out.<br>
>>>> >><br>
>>>> >> \documentclass{article}<br>
>>>> >> \usepackage{tikz}<br>
>>>> >> \usepackage[nogin]{Sweave}<br>
>>>> >> \begin{document}<br>
>>>> >> \begin{figure}[ht]<br>
>>>> >> \centering<br>
>>>> >> <<inline,echo=F,results=tex>>=<br>
>>>> >><br>
>>>> >> require(tikzDevice)<br>
>>>> >> tf <- tempfile()<br>
>>>> >> tikz(tf,width=5,height=5)<br>
>>>> >> x <- rnorm(100)<br>
>>>> >> plot(x)<br>
>>>> >> #Suppress "null device 1" from being printed<br>
>>>> >> dummy <- dev.off()<br>
>>>> >> cat(readLines(tf),sep='\n')<br>
>>>> >><br>
>>>> >> @<br>
>>>> >> \caption{caption}<br>
>>>> >> \label{fig:inline}<br>
>>>> >> \end{figure}<br>
>>>> >> \end{document}<br>
>>>> >><br>
>>>> >><br>
>>>> >> -Cameron<br>
>>>> >><br>
>>>> >><br>
>>>> >><br>
>>>> >> On Sun, Dec 6, 2009 at 9:02 AM, Gabor Grothendieck<br>
>>>> >> <<a href="mailto:ggrothendieck@gmail.com">ggrothendieck@gmail.com</a>> wrote:<br>
>>>> >> > I would like to create a single file that has my latex and<br>
>>>> >> > tikzDevice<br>
>>>> >> > output<br>
>>>> >> > as opposed to outputting the tikZ output into a separate file and<br>
>>>> >> > using<br>
>>>> >> > \input . The latex would be generated using cat statements in R.<br>
>>>> >> ><br>
>>>> >> > Can that be done? If so, can you provide a small example.<br>
>>>> >> ><br>
>>>> >> ><br>
>>>> ><br>
>>>> ><br>
>>><br>
>><br>
><br>
><br>
</div></div></blockquote></div><br>