Daróczi Gergely | 6 Dec 01:37 2010
Picon

Re: Problem with backslashes in default arguments for usage

Dear list members,

I have just read a thread (http://lists.r-forge.r-project.org/pipermail/roxygen-devel/2009-August/000077.html) from a year ago about "problem with backslashes" with roxygen, after I was searching for an asnwere for my problem.
I have some functions with default parameter set to '\n', e.g.:

   lineCount <- function(text, sep='\n') {
       ...
   }

Which purpose is to count new line ('\n') characters in a string.
The problem is that R CMD check gives a warning about:

Codoc mismatches from documentation object 'lineCount':
lineCount
  Code: function(text, sep = "\n")
  Docs: function(text, sep = " ")
  Mismatches in argument default values:
    Name: 'sep' Code: "\n" Docs: " "

The problem seems to me that caused by writing to the Rd file (writing to standard LaTeX files always requires to double escape characters for some purpose, e.g.: \\newline  - as I experienced).
If I put an extra backslash to the separator, like:

   lineCount <- function(text, sep='\\n') {
       ...
   }

The problem still presists, as in the code it looks like '\\n', but in the docs it looks '\n'.
Is there an easy solution for my problem? May be an extra tag in Roxygen which could define how to write the function's params to the Rd file?
Sorry if asked too obvious question, but I am lost after google-ing for a while.

Best regards,
Gergely Daróczi
<div>Dear list members,<div><br></div>
<div>I have just read a thread (<span class="Apple-style-span"><a href="http://lists.r-forge.r-project.org/pipermail/roxygen-devel/2009-August/000077.html">http://lists.r-forge.r-project.org/pipermail/roxygen-devel/2009-August/000077.html</a>)</span><span class="Apple-style-span">&nbsp;from a year ago about "problem with backslashes" with roxygen, after I was searching for an asnwere for my problem.</span>
</div>

<div><span class="Apple-style-span">I have some functions with default parameter set to '\n', e.g.:</span></div>
<div><span class="Apple-style-span"><div>

<br>
</div>
<div>&nbsp;&nbsp; lineCount &lt;- function(text, sep='\n') {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; ...</div>
<div>&nbsp;&nbsp; }</div></span></div>
<div><br></div>
<div>Which purpose is to count new line ('\n') characters in a string.</div>
<div>The problem is that R CMD check gives a warning about:</div>

<div><br></div>
<div>
<div>Codoc mismatches from documentation object 'lineCount':</div>
<div>lineCount</div>
<div>&nbsp;&nbsp;Code: function(text, sep = "\n")</div>

<div>&nbsp;&nbsp;Docs: function(text, sep = " ")</div>
<div>&nbsp;&nbsp;Mismatches in argument default values:</div>
<div>&nbsp;&nbsp; &nbsp;Name: 'sep' Code: "\n" Docs: " "</div>
<div><br></div>
<div>The problem seems to me that caused by writing to the Rd file (writing to standard LaTeX files always requires to double escape characters for some purpose, e.g.: \\newline &nbsp;- as I experienced).</div>

<div>If I put an extra backslash to the separator, like:</div>
<div><br></div>
<div><span class="Apple-style-span"><div><span class="Apple-style-span"><div>

&nbsp;&nbsp; lineCount &lt;- function(text, sep='\\n') {</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; ...</div>
<div>&nbsp;&nbsp; }</div>
<div><br></div>
<div>The problem still presists, as in the code it looks like '\\n', but in the docs it looks '\n'.</div>

<div>Is there an easy solution for my problem? May be an extra tag in Roxygen which could define how to write the function's params to the Rd file?</div>
<div>Sorry if asked too obvious question, but I am lost after google-ing for a while.</div>

<div><br></div>
<div>Best regards,</div>
<div>Gergely Dar&oacute;czi</div></span></div></span></div>
</div>
</div>

Gmane