我在R中有一个看起来像这样的列表
[1] 1067 576 0 0 0 786 0
我想要的是另一个列表,其排序方式是告诉元素的顺序从大到小,所以在这种情况下它会报告
1 6 2
也就是说,第一个元素是最大的元素,然后是第6个元素,然后是第二个元素。
思想?
答案 0 :(得分:5)
您似乎想要排除0。
chart: {
type: 'line',
zoomType: 'xy'
},
你也可以使用:
ctx.translate(x, y);
ctx.rotate(this.angle * this._TORADIANS);
ctx.translate(-x, -y); // this part is missed in your case
ctx.drawImage(this.img, this.x, this.y, this.width, this.height, x, y, this.width, this.height);
这相同。
答案 1 :(得分:0)
主题的另外两个变体:
freq <- c(1067,576,0,0,0,786,0)
Jeremy(ish)
order(-freq)[order(-freq) %in% which(freq != 0)]
理查德
order(-freq)[seq_along(freq[freq != 0])]
答案 2 :(得分:0)
或者只是:
order(-v)[1:sum(!!v)]
[1] 1 6 2