我目前正在尝试在R上运行MAPPER算法,并完成网站上的一些基本示例:
http://bertrand.michel.perso.math.cnrs.fr/Enseignements/TDA/Mapper.html
我使用的代码如下:
library(TDAmapper)
library(networkD3)
First.Example.data = data.frame( x=2*cos(0.5*(1:100)), y=sin(1:100) )
First.Example.dist = dist(First.Example.data)
First.Example.mapper <- mapper(dist_object = First.Example.dist,
filter_values = First.Example.data$x,
num_intervals = 6,
percent_overlap = 50,
num_bins_when_clustering = 10)
MapperNodes <- mapperVertices(First.Example.mapper, 1:100 )
MapperLinks <- mapperEdges(First.Example.mapper)
forceNetwork(Nodes = MapperNodes, Links = MapperLinks,
Source = "Linksource", Target = "Linktarget",
Value = "Linkvalue", NodeID = "Nodename",
Group = "Nodegroup", opacity = 1,
linkDistance = 10, charge = -400)
然而,当我运行此代码时,我不断收到此错误,我不知道如何修复:
Error in yaml.load(readLines(con), error.label = error.label, ...) :
argument "error.label" is missing, with no default
有人可以告诉我如何解决这个问题吗?
我已尝试重新安装R,TDAMapper和networkD3,而且或多或少似乎安装得很好。但是,我确实在安装networkD3期间收到了此消息,这可能/可能没有帮助诊断问题。
尝试访问网址&#39; https://mirrors.ebi.ac.uk/CRAN/bin/windows/contrib/3.4/BH_1.66.0-1.zip&#39;
download.file出错(url,destfile,方法,模式=&#34; wb&#34;,...):
无法打开网址 &#39; https://mirrors.ebi.ac.uk/CRAN/bin/windows/contrib/3.4/BH_1.66.0-1.zip&#39;另外:警告信息: 在download.file(url,destfile,method,mode =&#34; wb&#34;,...)中:
InternetOpenUrl失败:&#39;操作定时 出&#39;download.packages中的警告(pkgs,destdir = tmpd,available = 可用,:'BH'软件包下载尝试URL失败 &#39; https://mirrors.ebi.ac.uk/CRAN/bin/windows/contrib/3.4/plogr_0.1-1.zip&#39;
内容类型&#39; application / zip&#39;长度17919字节(17 KB)已下载 17 KB
答案 0 :(得分:0)
mapper
,mapperVertices
和mapperEdges
函数目前仅在TDAmapper
的开发版本中可用。您可以使用(必须安装devtools
包)安装它...
devtools::install_github("paultpearson/TDAmapper")
之后,您的示例应该有效。
downvote可能是因为你的“可重复”的例子不是“可重现的”,但这只是猜测,因为它不是我的。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>forceNetwork</title>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://cdn.rawgit.com/ramnathv/htmlwidgets/master/inst/www/htmlwidgets.js"></script>
<script src="https://cdn.rawgit.com/christophergandrud/networkD3/master/inst/htmlwidgets/forceNetwork.js"></script>
</head>
<body style="background-color: white;">
<div id="htmlwidget_container">
<div id="htmlwidget-1d269226bedddd51dcd0" class="forceNetwork html-widget" style="width:960px;height:500px;">
</div>
</div>
<script type="application/json" data-for="htmlwidget-1d269226bedddd51dcd0">{"x":{"links":{"source":[1,2,3,3,4,5,6,7,7],"target":[0,0,1,2,3,4,4,5,6],"value":[2,2,2,2,2,2,2,2,2],"colour":["#666","#666","#666","#666","#666","#666","#666","#666","#666"]},"nodes":{"name":["V1: 82, 57, 32, 7, 95, 70, 20, 45, 71, 8, 96, 33, 58, 83, 69, 6, 94, 31, 56, 81, 19, 44, 17, 18, 80, 43, 55, 68, 30, 5, 93","V2: 54, 4, 55, 17, 21, 46, 96, 58, 59","V3: 29, 92, 80, 67, 42, 71, 8, 33, 34, 84","V4: 79, 54, 4, 29, 16, 41, 47, 22, 66, 3, 91, 72, 9, 97, 34, 59, 84","V5: 85, 60, 35, 73, 10, 98, 15, 40, 41, 47, 22, 66, 3, 91, 28, 53, 78","V6: 86, 11, 10, 73, 48, 15, 65, 2, 27","V7: 61, 36, 99, 98, 23, 78, 40, 90, 52, 77","V8: 25, 50, 75, 61, 36, 11, 99, 24, 49, 74, 12, 100, 37, 62, 87, 27, 52, 77, 76, 51, 26, 1, 89, 64, 14, 39, 88, 63, 13, 38"],"group":[1,2,2,3,4,5,5,6]},"options":{"NodeID":"Nodename","Group":"Nodegroup","colourScale":"d3.scaleOrdinal(d3.schemeCategory20);","fontSize":7,"fontFamily":"serif","clickTextSize":17.5,"linkDistance":10,"linkWidth":"function(d) { return Math.sqrt(d.value); }","charge":-400,"opacity":1,"zoom":false,"legend":false,"arrows":false,"nodesize":false,"radiusCalculation":" Math.sqrt(d.nodesize)+6","bounded":false,"opacityNoHover":0,"clickAction":null}},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-1d269226bedddd51dcd0">{"viewer":{"width":450,"height":350,"padding":10,"fill":true},"browser":{"width":960,"height":500,"padding":10,"fill":true}}</script>
</body>
</html>