R:匹配两个向量的问题

时间:2015-12-19 23:00:19

标签: r match

我有一个名为var world = Snap('#globe'), lines = [], circles = []; for (var i = 50; i >= 0; i--) { var x = Math.floor(Math.random()*900) var y = Math.floor(Math.random()*900) var l = world.line(x, y, 450, 450).attr({ stroke: "#fff", strokeWidth: 2 }); lines.push(l) var c = world.circle(x, y, 4, 4).attr({ stroke: "#fff", strokeWidth: 3, fill: "#333" }); circles.push(c) }; var sun = world.circle(450,450,100,100).attr({ fill: "#333", stroke: "#fff", strokeWidth: 3, cursor: "-webkit-grab" }); function orbit() { for (var i = 0; i < 22; i++) { var x = Math.floor(Math.random()*900) var y = Math.floor(Math.random()*900) lines[i].animate({ "x1" : x, "y1" : y }, 6000, mina.ealastic) circles[i].animate({ "cx" : x, "cy" : y }, 6000, mina.ealastic) } setTimeout(function(){orbit()}, 6000, mina.ealastic); } orbit(); function proOrbit() { for (var i = 22; i < 44; i++) { var x = Math.floor(Math.random()*900) var y = Math.floor(Math.random()*900) lines[i].animate({ "x1" : x, "y1" : y }, 9000, mina.ealastic) circles[i].animate({ "cx" : x, "cy" : y }, 9000, mina.ealastic) } setTimeout(function(){proOrbit()}, 10000, mina.easeinout); } proOrbit(); function antiOrbit() { for (var i = 44; i <= 50; i++) { var x = Math.floor(Math.random()*900) var y = Math.floor(Math.random()*900) lines[i].animate({ "x1" : x, "y1" : y }, 10000, mina.easeinout) circles[i].animate({ "cx" : x, "cy" : y }, 10000, mina.easeinout) } setTimeout(function(){antiOrbit()}, 10000, mina.easeinout); } antiOrbit(); function light() { sun.animate({ r : 110 }, 1000, mina.backin, dark) } function dark() { sun.animate({ r : 40 }, 1000, mina.backout, light) } light(); start = function() { this.ox = parseInt(this.attr("cx")); this.oy = parseInt(this.attr("cy")); console.log("Start move, ox=" + this.ox + ", oy=" + this.oy); } var move = function(dx, dy) { this.attr({"cx": this.ox + dx, "cy": this.oy + dy}); for (var i = 0; i <= 50; i++) { lines[i].attr({ "x2": this.ox + dx, "y2": this.oy + dy }) } } var stop = function(dx, dy) { this.animate({ "cx": 450, "cy": 450 }, 2000, mina.elastic); for (var i = 0; i <= 50; i++) { lines[i].animate({ "x2": 450, "y2": 450 }, 2000, mina.elastic); } } sun.drag(move, start, stop) 的对象:

lengthData

一个叫> class(lengthData) [1] "numeric" > length(lengthData) [1] 19804 > head(lengthData) XLOC_000001 XLOC_000002 XLOC_000003 XLOC_000004 XLOC_000005 XLOC_000006 2796 5223 733 11433 1628 414

DEgenes

我需要使> class(DEgenes) [1] "integer" > length(DEgenes) [1] 19442 > head(DEgenes) XLOC_000001 XLOC_000002 XLOC_000003 XLOC_000004 XLOC_000005 XLOC_000007 0 0 1 0 1 0 lengthData的长度相同,即包含相同的基因。我尝试使用:

DEgenes

DElength = lengthData[DEgenes] 的长度仅为6124,这是DElength中1的基因的数量。

1 个答案:

答案 0 :(得分:2)

根据我的理解,您只需要lengthData中同样位于DEgenes的元素。所以你可以运行:

lengthData[names(lengthData) %in% names(DEgenes)]