rxDataStep
を使用してxdfファイルに新しい列を追加したいとします。この目的を達成するために、私はこのコードを書かれている: xdfファイルに新しい列を追加する
rxDataStep(nyc_jan_xdf,transformFunc = CashVsCard)
CashVsCard<-function(dataList)
{
if(dataList$payment_type==1)
{
dataList$cash_vs_Card="Card"
}
else
{
if(dataList$payment_type==2)
{
dataList$cash_vs_Card="Cash"
}
}
return(dataList)
}
は、私はこのエラーを取得:別の変数の値に基づいてベクトル化変換のため
The variable 'cash_vs_Card' has a different number of rows than other columns in the data: 1 vs. 10
Caught exception in file: CxAnalysis.cpp, line: 3830. ThreadID: 7288 Rethrowing.
Caught exception in file: CxAnalysis.cpp, line: 5347. ThreadID: 7288 Rethrowing.
Error in doTryCatch(return(expr), name, parentenv, handler) :
The variable 'cash_vs_Card' has a different number of rows than other columns in the data: 1 vs. 10
In addition: Warning messages:
1: In if (dataList$payment_type == 1) { :
the condition has length > 1 and only the first element will be used
2: In if (dataList$payment_type == 2) { :
the condition has length > 1 and only the first element will be used
「datalist」はどのような構造ですか? –
あなたは 'datalist'または' datallist'を意味しますか? –
投稿を編集しました – Kaja