简体   繁体   中英

Building a package in R

I'm trying to build a package and it works fine but I get a warning when running R CMD check my.package which is

* checking Rd metadata ... WARNING
Rd files with duplicated alias 'show,whitetest-method':
'show-methods.Rd' 'whitetest-class.Rd'

My package consists of only one function, which is saved in the file name.R . However, in this name.R file I first need to create a new class (called whitetest ) and then define the show method for it. It is quite simple and looks like this:

# Create the new class whitetest
setClass("whitetest", representation("list"))

# Specify the appearance of the output
setMethod("show", "whitetest", function(object) {
text1 <- "White's Test for Heteroskedasticity:"
cat(paste("\n", text1, "\n", sep = ""))
row <- paste(rep("=", nchar(text1)), collapse = "")
cat(row, "\n")
cat("\n")
cat(" No Cross Terms\n")
cat("\n")
cat(" H0: Homoskedasticity\n")
cat(" H1: Heteroskedasticity\n")
cat("\n")
cat(" Test Statistic:\n")
cat("", sprintf("%.4f", object$statistic), "\n")
cat("\n")
cat(" Degrees of Freedom:\n")
cat("", object$degrees, "\n")
cat("\n")
cat(" P-value:\n")
cat("", sprintf("%.4f", object$p.value), "\n")
})

I then run the package.skeleton() command on this name.R file. In my man folder the files show-methods.Rd and whitetest-class.Rd are the ones causing the problem. The show-methods file's first lines are:

\name{show-methods}
\docType{methods}
\alias{show-methods}
\alias{show,whitetest-method}

and the whitetest-class file's first lines are:

\name{whitetest-class}
\Rdversion{1.1}
\docType{class}
\alias{whitetest-class}
\alias{show,whitetest-method}

I get that these things are what's causing the warning, but how on earth do I get around this?

Okay, I found the solution. The line \\alias{show,whitetest-method} is in both show-methods.Rd and whitetest-class.Rd . That's a silly thing to miss and I was going to delete this thread but thought I'd leave it in case someone else would make the same mistake.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM