<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />私はマニュアル(Scripting Guide、Ch 11)を読み、'Nesting and Precedence'について説明していますが、他の人がパイプライン演算子のように動作するオプションを希望するかどうか疑問に思いましたマグリット演算子R)。ですから、積み重ねられたメッセージを括弧で括らなければならない代わりに、
((object << message 1)<< message 2)<< message 3
読みやすくなり、自然に左から右に流れます。
オブジェクト%>>%message1
%>>%message2
%>>%message3
あなたはこれをすることができます。 将来のメンテナンスには最善の方法ではないかもしれません。よく名前が付けられた変数は多くを明確にすることができます。
dt = open( "C:¥Program Files¥SAS¥JMPPRO¥13¥Samples¥Import Data¥bigclass_L.txt")
<< selectwhere(13 <=:age <= 15)<< invertRowSelection << deleterows
<< newcolumn( "halfage"、式(年齢/ 2))
<< selectwhere(row()<= 10)<< invertRowSelection <<代行;
selectWhere条件を変更することでinvertRowSelectionを消すことができます。
これは、新しいオブジェクトを作成しないメッセージ(<<サブセットなど)を選択したために機能します。 <<サブセットが使用されている場合は、後続のメッセージを新しいオブジェクトに送信するために追加の親が必要です。 サブセットを使用する方が削除を使用するよりも速いかもしれません。
6ヵ月後、私はむしろ少しモノリシックでないものを維持したいと思います。
allData = Open( "C:¥Program Files¥SAS¥JMPPRO¥13¥Samples¥Import Data¥bigclass_L.txt");
ageSubset = allData << selectwhere(13 <=:age <= 15)<<サブセット(選択行(1));
tenRows = ageSubset << selectwhere(Row()<= 10)<<サブセット(選択されたrows(1));
tenRows <<新しい列( "halfage"、式(age / 2));
閉じる(allData、nosave)。
閉じる(ageSubset、nosave);
やる気を引き出すために... 私は、他の人がこのR / magrittrの例をJSLでどのように記述するのかと思いました。
Four operations are performed to arrive at the desired data set, and they are written in a natural order: the same as the order of execution. Also, no temporary variables are needed. If yet another operation is required, it is straight-forward to add to the sequence of operations wherever it may be needed.
the_data < -
read.csv( '/ path / to / data / file.csv')%>%
サブセット(variable_a> x)%>%
変換(variable_c = variable_a / variable_b)%>%
ヘッド(100)