Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6142165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:20:59+00:00 2026-05-23T18:20:59+00:00

I use Roxygen to generate Rd files of my packages under development, but I

  • 0

I use Roxygen to generate Rd files of my packages under development, but I have some problems with 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 via cat() 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 (Rd files) 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 a question, but I am lost after Google-ing for a while.


History: http://permalink.gmane.org/gmane.comp.lang.r.roxygen/24


UPDATE: use roxygen2!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:21:00+00:00Added an answer on May 23, 2026 at 6:21 pm

    I also ran into problems with too much escaped ” and vanishing \t. I ended up changing the parse.formals function in roxygen’s Rd2.R as follows:

      parse.formals <- function(partitum) {
        formals <- partitum$formals
        if (!is.null(formals)) {
          formals <- lapply(formals, trim)
          formals <- lapply(formals, paste, collapse=" ")
          name.defaults <- zip.c(names(formals), formals)
          args <-
            do.call(paste, c(Map(function(name.default) {
              name <- car(name.default)
              default <- cadr(name.default)
              if (! is.character (default)) {  # too much escaped. 
                                               # Not sure when escaping is needed. 
                                               # param = c ("x", "y", "z") works now
                default <- gsubfn("\"(.*)\"",
                                  function(x)
                                  sprintf("\"%s\"", gsub("\"", "\\\\\"", x)),
                                  as.character(default))
              }
              default <- gsub ("\t", "\\\\t", default) # the tabs and newlines are already
              default <- gsub ("\n", "\\\\n", default) # tab and newline here.
              if (is.null.string(default))
                name
              else
                sprintf('%s=%s', name, default)
            },
                                 name.defaults),
                             sep=', '))
    
          append.Rd(usageTag(parse.function.name(partitum), args))
        }
      }
    

    Hope that helps and doesn’t break anything else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Use case: we have some project meta-data files which we want tracked, but are
Use Case: I have some repo on GitHub, someone forked it and added new
Use PHP and MySQL. I have an array, P, which contains the value of
use javascript or other method ? have any recommendation?
use case example I have a servlet that is receiving login requests. If a
Use default: <input type=radio name=restype value=resdef onfocus=document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true; checked=checked /><br
I have a simple shell script that builds my Roxygen documents, builds the package,
I've recently been pointed towards Roxygen to solve my documentation woes/laziness. But then there's
use ruby 1.9.2 rails 3.1.3 rake 0.8.7 and when rake cucumber start i have
tl;dr version of my question If I want to import packages, do I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.