Rのメモ

メモ1

2本のベクトルx, yがある時に、x, y両方に含まれている要素を調べる方法。

> x <- 2 * (1:10)
> y <- 3 * (1:10)
> x[apply(outer(x, y, '=='), 1, any)]
[1]  6 12 18

メモ2

Rの付置演算子emacsのalignで揃える。

;; align for R
(require 'align)
(add-to-list 'align-rules-list
             '(ess-assignment-operator
               (regexp . "\\(\\s-*\\)<-[^#\t\n]")
               (repeat . nil)
               (modes  . '(ess-mode))))
http://d.hatena.ne.jp/yag_ays/20090712/1247346981

永続付置が使えないので、

(regexp . "\\(\\s-*\\)<?<-[^#\t\n]")

と変更。