I have a list which contains data frames with three columns and different number of rows. As an example one of them is as the table below. df[[2]]. I want to extract for each of the data frame the row where the column "D" is "TRUE" for the first time. for example, the row number 5 in the table below. How can I extract the information? And how can I extract the first and last element of colunmn A from my list? I tried below:
df$first_element_A = unlist(X = df, FUN = function(p_)
{
p_[which(p_$A)][1]
}))
df$A = 40.51
df$m = 15
df$D = TRUE
I have reach to this code, but not sure how to fix it:
df$A = sapply(X = df, FUN = function(p_) {which (p$D==TRUE )[1]}
