hejseb
hejseb

Reputation: 2164

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?

Upvotes: 3

Views: 432

Answers (1)

hejseb
hejseb

Reputation: 2164

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.

Upvotes: 2

Related Questions