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 8912891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:19:49+00:00 2026-06-15T04:19:49+00:00

I have two functions in the same family. I am documenting with roxygen2 and

  • 0

I have two functions in the same family. I am documenting with roxygen2 and can put them together in the same help file but do not know how to make the usage field in the documentation have both functions.

I tried:

#' @usage matrix2vectors(cor.mat) vectors2matrix(cor.vect)

This gives:

matrix2vectors(cor.mat) vectors2matrix(cor.vect)

I tried comma separated and it gives just the first and I tried separate usage tags and it uses just the first one.

How can I make two items in the usage field with roxygen and so they’ll be on separate lines (eg ?lapply)?

EDIT: Per GeeSee’s question, the whole .R file

#' Convert Between Correlation Matrix and Upper Triangle Dataframe  
#' 
#' Tools to convert between a correlation matrix and a dataframe of upper triangle 
#' values and variable components.  The dataframe is more intuitive for applying 
#' functions while the correlation matrix is more intuitive to visualize.
#' 
#' @aliases matrix2vectors, vectors2matrix
#' @usage matrix2vectors(cor.mat)
#' @usage vectors2matrix(cor.vect)
#' @rdname matrix2vectors
#' @param cor.mat A square, symetrical matrix with a diagonas of 1s (a correlation matrix).
#' @param cor.vect A dataframe with the row variables of the correlation matrix in the first 
#' column, the column names in the second column and the corresponding correlations in the 
#' third column.
#' @export
#' @examples
#' (mat <- round(cor(mtcars[, 1:5]), 2))
#' matrix2vectors(mat)
#' cor.vect <- matrix2vectors(round(cor(mtcars[, 1:5]), 2))
#' vectors2matrix(cor.vect)
matrix2vectors <- function(cor.mat) {
    nmscor <- colnames(cor.mat)
    rows <- nmscor[1:(length(nmscor)-1)]
    cols <- nmscor[2:length(nmscor)]
    rowdim <- 1:length(rows)
    row.var <- rows[unlist(lapply(seq_along(rowdim), function(i) rowdim[1:i]))]
    col.var <- rep(cols, 1:length(cols))
    cors <- cor.mat[upper.tri(cor.mat)]
    data.frame(row.var, col.var, cors)
}
#' @export

#' @export
vectors2matrix <- function(cor.vect) {
    dimnms <- unique(c(as.character(cor.vect[, 1]), 
        as.character(cor.vect[, 2])))
    mat <- matrix(NA, length(dimnms), length(dimnms))
    mat[upper.tri(mat)] <- cor.vect[, 3]
    diag(mat) <- 1
    dimnames(mat) <- list(dimnms, dimnms)
    mat[lower.tri(mat)] <- t(mat)[lower.tri(mat)]
    mat
}
#' @export
  • 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-06-15T04:19:50+00:00Added an answer on June 15, 2026 at 4:19 am

    I think you want to use @rdname and abandon the idea of using @usage

    So, pick a name and use it for all of them. e.g. add this to all your roxygen blocks

    #' @rdname matrix2vectors

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

Sidebar

Related Questions

I have two functions whose underlying logic is the same but in one case
I have two functions that have different enough logic but pretty much the same
So I have two jquery functions that bassically do the same, but on 2
I have two functions in the same file, both accessed externally. One of the
Is there a way to have two functions with the same name but with
Right, I have two functions. Both take exactly the same file input. run2D works
I have two functions that i'm hoping i can put into one and can
I have two functions that carry out the same functionality But has been implemented
I have two functions, but one of the functions is only called from the
I have two functions that I can use to make an array: def makelist(size):

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.