更新时间:2023-11-29 20:18:04
有许多内置插件可以执行类似的操作. indexin
为您提供在b
中找到a
元素的索引(如果不存在,则为0,这类似于R的match
). setdiff
为您提供a
中的元素,而这些元素不在b
中.您很可能可以使用它们来做您想做的-在julia中构造用于过滤的临时布尔数组并不像R中那样意识形态,因为它通常会创建额外的不必要分配.
There are a number of built-ins that do something similar. indexin
gives you the indices in b
where the elements of a
are found (0 if it is not there - this is similar to R's match
). setdiff
gives you the elements in a
that are not in b
. It is likely you'll be able to do what you want with these - constructing temporary boolean arrays for filtering is not so ideomatic in julia as in R, as it generally creates an extra, unnecessary allocation.