Select missing values in numeric vector R

Dear all

I have a question about 2 numeric vectors. I have a dataframe of 650 values, where some values are missing, e.g.:

1, 2, 3, 4, 6, 8, 10, ... 650

I want that R returns the values 5 and 9 in this case through the whole numeric vector. Can I use setdiff somehow? Or another function?

Using your example, here's one way to find the missing values using setdiff

dat <- data.frame(x = sort(sample(650, 600)))
y <- 1:650
setdiff(y, dat$x)

Thanks very much for your response!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.