我正在寻找setorder()的东西来完成key()函数对setkey()的作用。也就是说,我在fn3的第一行放什么?就目前而言,fn1()的最后一行输出是1:10而不是10:1
<div class="modal-body">
<form id="form" class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="post-form">
{% csrf_token %}
<div id="error-div">
</div>
<div class="form-group" csrf="{{ csrf_token }}">
<label class="col-sm-2 control-label" for="exam_number">Number</label>
<div class="col-sm-10">
<select class="form-control" id="exam_number" name="exam_number">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select>
</div>
</div>
<div class="form-group">File</label><br>
<div class="col-sm-10">
<input name="exam_file" type="file" accept="*" multiple required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
</div>
</div>
</div>
答案 0 :(得分:0)
这样的东西?
if(is.unsorted(dt2[,a])){
ord <- "b"
} else {
ord <- "a"
}
查看?is.unsorted()
答案 1 :(得分:0)
在名为data.table
的{{1}}中有一个未导出的功能可以执行您想要的操作。当然,不建议依赖未导出的功能,因为它们可能会突然改变。它要求您先了解哪些列可用于对表进行排序。
is.sorted
请注意警告,即使在内部它也没有那么多使用。根据源代码中的注释:
这仅供用户/调试用于检查/测试有效密钥;例如
data.table:::is.sorted(dt, 'a') # [1] TRUE # Warning message: # In data.table:::is.sorted(dt1, "a") : # Use 'if (length(o<-forderv(DT,by))) ...' for efficiency in one step, so you have o as well if not sorted.