我正在为 qmethod 做贡献R 包,我刚刚写了一个函数来创建一堆 ggplot2
对象。
该函数工作正常,但构建和 R CMD Check
警告我:
replacing previous import by ‘ggplot2::%+%’ when loading ‘qmethod’
我看过SE posts和@hadley 的 book但无法弄清楚问题所在。
这是我的
NAMESPACE
的相关部分:import("ggplot2",
"stringr")
import("psych")
importFrom("plyr","count")
importFrom("reshape2","melt")
importFrom("digest", "digest")
importFrom("RColorBrewer", "brewer.pal")
这是我的
DESCRIPTION
的一部分:Imports:
digest,
psych,
knitr,
RColorBrewer,
stringr,
ggplot2,
plyr,
reshape2
我在函数中调用 ggplot2 函数的部分
array.viz.R
看起来像这样(以及更多):g <- ggplot(
data = array.viz.data
,aes(
x = fsc # factor scores, always same variable bc dataframe is constructed for every factor array by above loop
,y = ycoord # just the random ycoord for viz
,ymax = max(ycoord)
,ymin = 0
#,label = item.wrapped # this for some reason causes an error
)
)
g <- g + geom_tile( # add background tiles
aes(
fill = item.sd
)
)
Ps.:你可以在这里找到整个当前的工作:https://github.com/maxheld83/qmethod/tree/array-viz
Pps.: 我知道
ggplot2
本身导入了一堆我也导入的函数(例如 reshape2
),所以我有一种预感,这可能是一个问题。
最佳答案
原来,import("psych")
是违规包。
好像又要导出了ggplot::%+%
,虽然我想不出为什么会这样。
无论如何,修复是:
importFrom("psych", "principal") # that's the function we were using
关于r - 在包中使用 ggplot2 时,讨厌的 ggplot2 命名空间冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28662289/