Can't find the missing values in dataframe

Without a reprex, I can't understand what's happening clearly. See the FAQ: How to do a minimal reproducible example reprex for beginners.

This error is something that can happen when using a function out of place. For example

xj <- LETTERS
xj[5]
#> [1] "E"

i <- function() pi
# this is the call of a function
i()
#> [1] 3.141593
# here is a "closure"
i
#> function() pi
xj[i]
#> Error in xj[i]: invalid subscript type 'closure'

# within the `for` function, i
# is no longer a closure, because
# it is being invoked in the .Local
# environment
for(i in 1:3) print(xj[i])
#> [1] "A"
#> [1] "B"
#> [1] "C"

Created on 2023-07-19 with reprex v2.0.2

Here's what I mean by using complete.cases

# the data frame has 32 rows
dim(mtcars)
#> [1] 32 11
# introduce a missing value in the first row
mtcars[1,1] <- NA
# subset by the rows with no missing values
# dimension now shows one fewer row
mtcars[complete.cases(mtcars),] |> dim()
#> [1] 31 11