df <- data.frame(stringsAsFactors = FALSE, x = c(NA, "3", "NA", "7", "1", "2", "3"), y = 1:7)
To omit all NA's in column 3: data.new <- na.omit (data[-3])
How do you know that the [-3] refers to the 3rd column, and not the 3rd row?
This has nothing to do with the na.omit function.
na.omit
Check the documentation of Extract.data.frame:
When [ and [[ are used with a single vector index (x[i] or x[[i]]), they index the data frame as if it were a list
Please note that you are using data, but you haven't defined it yet.
data
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.