質問を伝えるために、このサンプルデータを提供しています。
aid=c(1,2,3,4,5,6,7,8,9,10)
foson=c(0,1,2,0,6,9,0,0,3,0)
fosof=c(0,0,2,3,0,0,0,5,0,0)
data=data.frame(aid,foson,fosof)
次に、次の条件でdata $ histという名前の新しい変数(列)を作成する必要があります。
if foson==0 and fosof==0, then hist = 0;
if foson >=1 and fosof==0, then hist = 1;
if foson==0 and fosof>=1, then hist = 2; and
if foson>=1 and fosof>=1, then hist = 3
「ifelse」機能を使おうとしましたが、足りませんでした。
質問が十分に明確であることを願っています。
すべての助けをありがとう、
バゾン