Как предотвратить Следующий объект маскируется от «пакета:»: проблема/предупреждение полностью при загрузке пакета?

Когда я загружаю созданный мной пакет, я получаю следующее предупреждение:

«Следующий объект замаскирован из ‘package:utils’:combn»

хотя я использовал combinat::combn в определениях функций в файлах .R папки «R» в рабочем каталоге R.

Нет ли способа избавиться от предупреждения «... объект замаскирован от ...»? (Я вообще не хочу маскировать расческу; см. сообщение Грегора ниже.)

Я добавил префикс «combinat::» в свои определения функций в моем пакете везде, где я хочу использовать комбинацию combinat, чтобы не получать вышеуказанное предупреждение (смешение combinat::combn с utils::combn).

gctemplate — это функция пакета causfinder (я удалил «combinat::» для тех, кто хочет понять функцию; когда я качаю префикс «combinat::» везде, где вижу combn в функции gctemplate, Я все еще получил вышеуказанное предупреждение):

#' gctemplate
#'
#' Granger causality template for a given system in the desired pattern.
#'
#' Assume a system in which its Granger causality relations among its variables will be searched is given. For the variables of this system (with nvars variables), some varibles may cause (causers, like independents) some others (those that are caused by causers, like dependents) conditional on some others in the system. The function gctemplate has three arguements to list all the possible causation pattern in which Granger causality will be searched. As is known, dependent and independent variables are not specified in the beginning of a Granger analysis, the analysis reveals them.
#'
#' @param nvars integer. The number of all the variables in a given system.
#' @param ncausers integer. The selected number of causer (independent-like) variables
#' @param ndependents integer. The selected number of variables that are caused by the causers, number of dependent-like variables
#' @return granger causality template
#' @author Erdogan Cevher erdogancevher@@gmail.com
#' @seealso \code{\link{conditionalGb}}
#' @examples
#' ## List all G-causalities in a VAR system of 5 variables that will be searched in the pattern of 1 
#' ## causer (like-independent) variable and 2 like-dependents conditional on 5-(1+2)=2 of the remaining 
#' ## variable(s) in the system. Varibles are assigned to numbers 1 to nvars. 
#' ## "1 2 5 3 4" in the rsulting line of gctemplate is to indicate the 
#' ## (conditonal, partial, etc.) G-causality from variable 1 to varibles 2 and 5 
#' ## conditonal on variables 3 and 4.
#' # gctemplate(5,1,2)
#' ## The number of all G-causalities to be searched in the above pattern.
#' #dim(gctemplate(5,1,2))[[1]]
#' @importFrom combinat combn
#' @export
gctemplate <- function(nvars, ncausers, ndependents){  
independents <- combn(nvars, ncausers)  
patinajnumber <-  dim(combn(nvars - ncausers, ndependents))[[2]]  
independentspatinajednumber <- dim(combn(nvars, ncausers))[[2]]*patinajnumber   
dependents <- matrix(, nrow = dim(combn(nvars, ncausers))[[2]]*patinajnumber, ncol = ndependents)  
for (i in as.integer(1:dim(combn(nvars, ncausers))[[2]])){     
dependents[(patinajnumber*(i-1)+1):(patinajnumber*i),] <- t(combn(setdiff(seq(1:nvars), independents[,i]), ndependents))  
}  
independentspatinajed <- matrix(, nrow = dim(combn(nvars, ncausers))[[2]]*patinajnumber, ncol = ncausers)  
for (i in as.integer(1:dim(combn(nvars, ncausers))[[2]])){     
for (j in as.integer(1:patinajnumber)){     
independentspatinajed[(i-1)*patinajnumber+j,] <- independents[,i]    
}}  
independentsdependents <- cbind(independentspatinajed, dependents)  
others <- matrix(, nrow = dim(combn(nvars, ncausers))[[2]]*patinajnumber, ncol = nvars - ncausers - ndependents)   
for (i in as.integer(1:((dim(combn(nvars, ncausers))[[2]])*patinajnumber))){    
others[i, ]  <- setdiff(seq(1:nvars), independentsdependents[i,])   
}  
causalitiestemplate <- cbind(independentsdependents, others)  
causalitiestemplate  
}  

Ниже приводится содержимое DESCRIPTION ФАЙЛА:

Package: causfinder  
Type: Package  
Title: A visual analyser for pairwise and multivariate conditional and partial  
Granger causalities. For a list of documented functions, use library(help =  
"causfinder")  
Version: 2.0  
Date: 2014-10-05  
Author: Erdogan CEVHER <[email protected]>  
Maintainer: Erdogan CEVHER <[email protected]>  
Description: Given a system of finite number of variables with their data in a  
matrix, the functions in the causfinder package analyze the pairwise and  
multivariate conditional and partial Granger causalities in a systematic  
and overall approach. By "overall approach" we mean that all the  
G-causalities among the variables in a certain desired pattern are  
calculated (the user then can retrieve his/her G-causality in interest as  
one element of the pattern). This pattern may correspond to pairwise or  
multivariate Granger causalities. Some of the functions in the package use  
bootstrapping whereas some others not. The analysis of the Granger  
causalities are performed via various ways; i.e., presenting the F  
statistics, p values, lower bounds and upper bounds of the bootstrapping  
values etc., and via presenting various plots and grid matrixes. For a list  
of documented functions, use library(help = "causfinder")  
Depends:  
    R (>= 3.0.2)  
Imports:  
    np(>= 0.50-1),RColorBrewer(>= 1.0-5),grid,scales(>= 0.2.4),boot(>= 1.3-11),calibrate(>= 1.7.2),combinat(>= 0.0-8),corpcor(>= 1.6.6)  
License: GPL (>= 3)  
LazyLoad: yes  
LazyData: yes  
URL: https://github.com/erdogancevher/causfinder  

ПРИМЕЧАНИЕ: переименовать функцию combn пакета combinat в combnnn и поместить ее содержимое (файл .R и т. д.) в папку моего пакета R; и применение процедуры повторной регистрации может не привести к вышеуказанному предупреждению. То, что я пытался получить, — это просто систематический способ предотвращения предупреждения, а не очень сложный/долгий способ, который я описал в этой заметке.


person Erdogan CEVHER    schedule 24.12.2014    source источник
comment
Вы можете переименовать свою собственную функцию во что-то другое или не экспортировать ее из своего пакета. Если вы загрузите пакет, который экспортирует имя функции, идентичное уже загруженному пакету, вы получите эту ошибку (и utils — это пакет по умолчанию).   -  person MrFlick    schedule 24.12.2014
comment
Я бы проголосовал за то, чтобы не использовать combn, если только вы не создали функцию, которая просто расширяет функциональность и синтаксис вызова utils::combn. Это довольно простая функция, с которой не следует возиться, если только вы не добавляете именованные аргументы справа от точек. (Но это не ошибка, а только предупреждение.)   -  person IRTFM    schedule 24.12.2014
comment
Имя моего пакета: causfinder, функция, использующая conbinat::combn, называется gctemplate. То есть я знаю, что utils — это пакет по умолчанию, и я не определял в своем пакете ни одной функции с именем combn. Я получил предупреждение в этих условиях.   -  person Erdogan CEVHER    schedule 24.12.2014
comment
Возможно, этот вопрос-ответ может помочь: Отключить сообщения при загрузке пакета в R   -  person zhaoy    schedule 24.12.2014
comment
@zhaoy, я проанализирую способ Дирка Эддельбюттеля (R›suppressMessages(library(causfinder)) решить, предотвращает ли он только предупреждения, но не ошибки.   -  person Erdogan CEVHER    schedule 24.12.2014
comment
Я подозреваю, что вы вызываете другой пакет, в котором есть функция с таким же именем, и вы импортируете весь пакет. В этом случае вы хотите импортировать только те функции, которые вам нужны.   -  person Tyler Rinker    schedule 24.12.2014
comment
Вы должны отредактировать свой вопрос, чтобы было ясно, если (а) вы не возражаете против маскировки combn, вы просто не хотите видеть предупреждение об этом, или (б) вы вообще не хотите маскировать combn и с этим проблемы.   -  person Gregor Thomas    schedule 24.12.2014
comment
@Грегор, ты прав. Мой вопрос (б) в вашем посте. Думаю теперь, как отразить то на вопрос. Вы также можете предложить сдачу. Я попытался добавить префикс combinat::, чтобы полностью избавиться от проблемы. К сожалению, не решил.   -  person Erdogan CEVHER    schedule 25.12.2014
comment
@Tyler Rinker, в моем файле пространства имен (автоматически сгенерированном roxygen2 (4.1.0)) есть строка importFrom(combinat,combn). Да, я хотел использовать только несколько функций из пакета combinat.   -  person Erdogan CEVHER    schedule 25.12.2014
comment
@GSee, я просто скопировал и вставил тело функции (с разметкой, отличной от roxygen2), и это дало результат. › gctemplate(5,1,2) [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 1 2 4 3 5 ... .......................... [30,] 5 3 4 1 2. Интересно, какую ошибку вы получили? Что вы имеете в виду: выдал ли gctemplate ошибку ИЛИ вы не получили, что объект замаскирован от предупреждения?   -  person Erdogan CEVHER    schedule 25.12.2014
comment
У меня не было ни ошибки, ни предупреждения. Это моя точка зрения. Когда я создаю пакет, созданный с использованием предоставленной вами информации, я могу загрузить его, не получая предупреждения о том, что combn замаскирован.   -  person GSee    schedule 25.12.2014
comment
Ваш пакет проходит R CMD check без каких-либо предупреждений или примечаний? Где-то мог быть случайный library звонок. Если вы поместите код в этот репозиторий github, мы могли бы взглянуть.   -  person GSee    schedule 25.12.2014
comment
@GSee, да, у меня нет проблем с этим; он прошел проверку двумя способами: A. Командная строка Windows: 1. Пуск – cmd – Enter. Затем рабочий каталог R cd C:\Users\erdogan\Documents\Revolution 2. Проверка CRAN: R CMD check causfinder B. Из Revolution R Ent Console: devtools::check(C:/Users/erdogan/Documents/Revolution/causfinder ). Я просто хотел узнать, как решить проблему в целом. Предупреждение о том, что объект замаскирован, не препятствует правильной проверке пакета.   -  person Erdogan CEVHER    schedule 25.12.2014
comment
Если пакет не подключен, и все, что вы делаете, это импортируете эту функцию в пространство имен вашего пакета, а не экспортируете ее, вы не должны получать это предупреждение. Я попробовал это, создав пакет под названием test, который использует ваше ОПИСАНИЕ и вашу функцию, и не получил предупреждения, когда я вызываю library(test). Если я позвоню library(combinat), я получу предупреждение.   -  person GSee    schedule 25.12.2014


Ответы (1)


Если объект в верхней части пути (объект, затеняющий объект, который вам действительно нужен) — это то, без чего вы можете обойтись, вы можете использовать команду

rm(object_name)

При выполнении:

требуется (ISLR)

Я получаю сообщение:

The following object is masked _by_ ‘.GlobalEnv’

Так что это исправлено, делая

rm(Auto)

Теперь я ссылаюсь на Auto из пакета ISLR, а не на GlobalEnv.

person Noel Evans    schedule 19.02.2015