[R] odfWeave: Combining multiple output statements in a function

Jan van der Laan rhelp at eoos.dds.nl
Fri Sep 16 16:07:53 CEST 2011


Page 7 in my version of formatting.odt (to be sure I have the right  
version I downloaded the latest odfWeave from CRAN) discusses  
registering style definitions and "Examples of Changing Styles for  
Tables, Paragraphs, Bullets and Pages" which has nothing to do with my  
question (as far as I can tell).  Could you perhaps just tell me how I  
should combine the output of multiple odf* calls inside a function?

Thanks again.

Jan


Quoting Max Kuhn <mxkuhn at gmail.com>:

> formatting.odf, page 7. The results are in formattingOut.odt
>
> On Thu, Sep 15, 2011 at 2:44 PM, Jan van der Laan <rhelp at eoos.dds.nl> wrote:
>> Max,
>>
>> Thank you for your answer. I have had another look at the examples (I
>> already had before mailing the list), but could find the example you
>> mention. Could you perhaps tell me which example I should have a look at?
>>
>> Regards,
>> Jan
>>
>>
>>
>> On 09/15/2011 04:47 PM, Max Kuhn wrote:
>>>
>>> There are examples in the package directory that explain this.
>>>
>>> On Thu, Sep 15, 2011 at 8:16 AM, Jan van der Laan<rhelp at eoos.dds.nl>
>>>  wrote:
>>>>
>>>> What is the correct way to combine multiple calls to odfCat, odfItemize,
>>>> odfTable etc. inside a function?
>>>>
>>>> As an example lets say I have a function that needs to write two
>>>> paragraphs
>>>> of text and a list to the resulting odf-document (the real function has
>>>> much
>>>> more complex logic, but I don't think thats relevant). My first guess
>>>> would
>>>> be:
>>>>
>>>> exampleOutput<- function() {
>>>>   odfCat("This is the first paragraph")
>>>>   odfCat("This is the second paragraph")
>>>>   odfItemize(letters[1:5])
>>>> }
>>>>
>>>> However, calling this function in my odf-document only generates the last
>>>> list as only the output of the odfItemize function is returned by
>>>> exampleOutput. How do I combine the three results into one to be returned
>>>> by
>>>> exampleOutput?
>>>>
>>>> I tried to wrap the calls to the odf* functions into a print statement:
>>>>
>>>> exampleOutput2<- function() {
>>>>   print(odfCat("This is the first paragraph"))
>>>>   print(odfCat("This is the second paragraph"))
>>>>   print(odfItemize(letters[1:5]))
>>>> }
>>>>
>>>> In another document this seemed to work, but in my current document
>>>> strange
>>>> odf-output is generated.
>>>>
>>>> Regards,
>>>>
>>>> Jan
>>>>
>>>> ______________________________________________
>>>> R-help at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide
>>>> http://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>
>>>
>>>
>>
>>
>
>
>
> --
>
> Max
>



More information about the R-help mailing list