3

パッケージをビルドしようとしていますが、正常に動作しますが、実行時に警告が表示されますR CMD check my.package

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

私のパッケージは、ファイルに保存されている 1 つの関数のみで構成されていますname.R。ただし、このname.Rファイルでは、まず新しいクラス ( という名前) を作成し、そのクラスのメソッドをwhitetest定義する必要があります。showそれは非常に単純で、次のようになります。

# 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")
})

次に、このファイルに対してpackage.skeleton()コマンドを実行します。name.R私のmanフォルダでは、ファイルshow-methods.Rdとファイルwhitetest-class.Rdが問題の原因となっています。show-methodsファイルの最初の行は次のとおりです。

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

whitetest-classファイルの最初の行は次のとおりです。

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

これらが警告の原因であることはわかりましたが、一体どうすればこれを回避できますか?

4

1 に答える 1

2

さて、私は解決策を見つけました。行\alias{show,whitetest-method}はとの両方show-methods.Rdにありwhitetest-class.Rdます。それは見逃すのはばかげたことで、私はこのスレッドを削除するつもりでしたが、他の誰かが同じ間違いを犯した場合に備えて、このスレッドを残すと思いました。

于 2013-02-27T21:09:39.637 に答える