使用R 3.0.0 for Windows中的{diagram}的流程图
我正在尝试使用图表包(v 1.6)在R中重新制作流程图.我能够使用这个确切的脚本(我从图表文档中的示例中修改)制作图表,但是一旦我将R更新为3.0.0,坐标函数就会给我一个错误.这是一个例子:
library(graphics) library(diagram) par(mar = c(1,1,1)) openplotmat() elpos<-coordinates(c(1,2,4)) Error in (function (classes,fdef,mtable) : unable to find an inherited method for function ‘coordinates’ for signature ‘"numeric"’ 我还是R和代码等新手,所以当我运行traceback()时,我真的不明白它告诉我的是什么: 3: stop(gettextf("unable to find an inherited method for function %s for signature %s",sQuote(fdef@generic),sQuote(cnames)),domain = NA) 2: (function (classes,mtable) { methods <- .findInheritedMethods(classes,mtable) if (length(methods) == 1L) return(methods[[1L]]) else if (length(methods) == 0L) { cnames <- paste0(""",sapply(classes,as.character),""",collapse = ",") stop(gettextf("unable to find an inherited method for function %s for signature %s",domain = NA) } else stop("Internal error in finding inherited methods; didn't return a unique method",domain = NA) })(list("numeric"),function (obj,...) standardGeneric("coordinates"),<environment>) 1: coordinates(c(1,4)) 大多数情况下,我不知道为什么coordinates()不会在更新后工作.任何有关它的见解,以及可能的回溯翻译将是一个巨大的帮助.谢谢! 解决方法
我不能像问题那样回答这个问题.最初,我无法重现您的错误:
library(diagram) openplotmat() (elpos1 <- diagram::coordinates(c(1,4))) # [,1] [,2] # [1,] 0.500 0.875 # [2,] 0.500 0.625 # ... 查找同名函数 但是,寻找坐标函数的其他实例会发现: help.search('coordinates',fields='name') # Help files with name matching 'coordinates' using fuzzy matching: # # diagram::coordinates coordinates of elements on a plot # sp::coordinates-methods retrieve (or set) spatial coordinates # sp::coordinates sets spatial coordinates to create spatial data,or retrieves spatial # coordinates # sp::coordnames retrieve or assign coordinate names for classes in sp 此输出搜索所有已安装(不一定已加载)的包.由此看来,sp也有一个.在用例中使用其版本会产生错误. 包装订单(或蒙面功能) 加载包的顺序很重要,因为后来加载的函数中的函数会掩盖先前加载的包中相同名称的函数.特别: # ensure we have neither package loaded detach(package:diagram,unload=TRUE) # ignore errors if not loaded detach(package:sp,unload=TRUE) # ignore errors if not loaded library(diagram) library(sp) # Attaching package: 'sp' # # The following object is masked from 'package:diagram': # # coordinates 此消息告诉您,对coordinate()的简单调用将使用sp中的版本而不是图中的版本. (对于下面的每个代码块,我使用上面的detach()来确保包和它的nameSpace都不在.) 在按顺序加载库之后,使用sp版本会产生相同的错误:diagram,sp: library(diagram) library(sp) # Attaching package: 'sp' # # The following object is masked from 'package:diagram': # # coordinates (elpos <- coordinates(c(1,4))) # Error in (function (classes,mtable) : # unable to find an inherited method for function 'coordinates' for signature '"numeric"' traceback()与您提供的相同. 撤消加载订单的工作原理: library(sp) library(diagram) # Attaching package: 'diagram' # # The following object is masked from 'package:sp': # # coordinates (elpos <- coordinates(c(1,] 0.500 0.625 # ... 请注意,警告现在告诉您sp :: coordinates()现在已被屏蔽. 当怀疑时,明确无误 如果对于调用哪个版本有任何疑问,我们可以随时强制使用我们打算使用的版本: (elpos <- diagram::coordinates(c(1,] 0.500 0.625 # ... 我觉得有点偏离这个作为答案,因为我正在解决你的问题,而不一定是陈述的问题.如果你仍然需要搜索traceback()的结果,请继续提示答案.但是,在那个努力中,我找不到.findInheritedMethods(),但是当diagram :: coordinates期望一个向量指定每行中元素的数量,或者带有元素位置的2-columned矩阵,或’NULL’时,它是有意义的.,而sp :: coordinates期待从“Spatial”类派生的对象(绝对不是简单的向量). (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-8 – Win8作为自适应/辅助技术的平台
- windows 修改远程桌面默认端口及对应的防火墙设置
- ms-access – Microsoft Access中的Scope_Identity()
- windows-server-2008 – 仅使用1个程序运行RDP会话
- 在Windows环境中进行部署
- 安装了哪个版本的Windows Management Framework?
- 为了在Windows应用程序的c#中结束,End(VB6)的等价物是什么?
- 如何使用NetCat for Windows将二进制文件发送到TCP连接?
- 如何从批处理文件中将行号添加到文本文件中(Windows)
- windows – 如果我调用GetOpenFileNameA,GetOpenFileNameW会