在R里用TramineR包的seqtreedisplay函数绘制决策树,需要用到Graphviz,于是去官网下载了graphviz-8.1.0 (64-bit),也在系统变量里添加了Graphviz的路径,但在R里运行仍然报错,说没有找到Graphviz或建议我直接添加到PATH环境变量里,但这些我都已经安装和添加好了,为什么还是会报错呢?
报错代码如下:
> seqtreedisplay(st, type = "d", border = NA)
[!!] In seqtreedisplay() : axes is deprecated, use xaxis instead.
[!!] In seqtreedisplay() : axes is deprecated, use xaxis instead.
[!!] In seqtreedisplay() : axes is deprecated, use xaxis instead.
[>] GraphViz version found.
ϵͳ�Ҳ���ָ����·����
Error in disstreedisplayInternal(tree = tree, filename = filename, tmpdisstree = tmpdisstree, :
[!] GraphViz was not found. If you haven't, please install GraphViz to use this function: see http://www.graphviz.org
[!] If GraphViz is installed on your computer, you need to specify the GraphViz installation directory using the argument gvpath='installdir'
[!] You can also add this directory to the PATH environment variable
[!] GraphViz installation directory usually looks like 'C:\Program Files\GraphViz'
Graphviz已添加到系统变量path中:
【以下回答由 GPT 生成】
首先,根据错误提示,您已经安装了GraphViz,并将其添加到系统变量中。然而,R仍然无法找到GraphViz。一种可能的原因是,R启动时没有加载新的系统环境变量。您可以尝试重新启动R并检查问题是否仍然存在。
如果重新启动R后问题仍然存在,您可以尝试以下解决方案:
确保GraphViz的安装目录路径是正确的,可以打开文件资源管理器,导航到GraphViz的安装目录,确认是否与您在系统变量中添加的路径匹配。如果不匹配,请更正路径并重新启动R。
检查GraphViz的版本是否与R包所需的版本兼容。可以在R中运行以下代码获取GraphViz的版本信息:
system("dot -V")
确保返回的版本与TramineR包所需的版本一致。
gvpath
参数来告诉R GraphViz的安装目录。在运行seqtreedisplay
函数时,使用gvpath
参数将GraphViz的安装目录传递给函数。例如:seqtreedisplay(st, type = "d", border = NA, gvpath = "C:/Program Files/GraphViz")
确保将"C:/Program Files/GraphViz"
替换为GraphViz的实际安装目录。
Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:/Program Files/GraphViz/bin", sep = ";"))
请确保将"C:/Program Files/GraphViz/bin"
替换为GraphViz的实际安装目录。
如果尝试上述解决方案后问题仍然存在,我无法为您提供更准确的解决方案。建议您咨询TramineR包的开发者或在相关论坛上寻求帮助。