To remove NA’s from a vector use the following code:
Vec <- Vec[!is.na(Vec)]
For example:
Vec <- c(1, 100, NA, 10,NA,5,6,7,8,9,4,3,5,NA)
Vec <- Vec[!is.na(Vec)]
Vec
[1] 1 100 10 5 6 7 8 9 4 3 5
You can also use the na.rm argument inside the max function to find the maximum number.
For example:
Vec <- c(1, 100, NA, 10,NA,5,6,7,8,9,4,3,5,NA)
max(Vec, na.rm = TRUE)
Output:
[1] 100
If you want to explore more in R programming then watch this R programming tutorial for beginner: