I have the following data which only has the last column on some occasions, and I'm trying to write an IF statement on this condition. When the column does not appear or when the column has an NA value I want this to return TRUE. As seen in my example below this works in position [[1]], but returns logical(0) for position [[2]]. Does anyone know why this is and how i can also get the statement to read TRUE or FALSE in position 2?
example data
df
[[1]]
Score didbreak break
1 6 FALSE <NA>
2 6 FALSE 9
3 5 FALSE <NA>
[[2]]
Score didbreak
1 3 FALSE
2 4 FALSE
[[3]]
Score didbreak
1 9 FALSE
2 8 FALSE
3 8 FALSE
if statement used (part thats an issue)
if(nrow(df[[xx]])==3 & !is.na(df[[xx]]$Score[3]) & (is.na(df[[xx]]$break[3]) | is.null(df[[xx]]$break[3]))) { }
So this works for the top position [[1]] as there is an NA value in row 3 of the data, but in position [[2]] it returns logical(0) as there is no break column. The is.null bit works fine however
(ignore the breif names etc ive edited it down here)