500 行で、1 行あたり少なくとも 12 列のデータ フレームがあります。一部の行には、より多くの列があります。私がやりたいことは、行ごとに最後に入力されたセルの内容を含む変数を作成することです。
dput (ヘッド (calls_with_overlap, 10))
A B C D
1. aknasd kasdknsd kasdkas kasdpa
2. asdhad none
3. apihsd piahsdas ashpidapishd phasd askdn wads
4. kasdas none
私がこれまでに試したことは次のとおりです。
if (calls_with_overlap$Overlap[10] = "none")
{
Ending <- TRUE
}
else (Ending <- FALSE)
if (Ending == FALSE)
{
for (q in 1:1024) #max is 1024 columns. perhaps not best way for number of columns.
{
EndingCell <- c(10 + q)
EndingCellcontents <- calls_with_overlap[h,EndingCell] # h is from an outer loop, going through each row.
if (EndingCellcontents != ""){
EndingCellcontents[q] <- EndingCellcontents}
last <- length(EndingCellcontents)
last<- EndingCellcontents[last]
}}
「なし」と表示されていない限り、「最後」に各行の最後に入力されたセルを含めたいと思います。B列から。
つまり、この場合
last
[1] kasdpa
[2] wads
これが初心者の質問である場合は申し訳ありませんが、私はゼロからプログラミングを教えています。