What is the purpose of the na.omit() function in R?

Instruction: Explain how na.omit() is used in data cleaning and provide an example of its application.

Context: This question tests the candidate's ability to manage missing data, a common issue in data analysis.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

For an ordinary data frame, na.omit removes rows containing missing values in any column and records omitted row positions in a na.action attribute. It does not prove that the remaining data is unbiased or otherwise valid.

df <- data.frame(id = 1:4, x = c(10, NA, 30, 40), note = c("a", "b", NA,...

Related Questions