r find nas in dataframe
# Step 1: Create a sample dataframe
df <- data.frame(
ID = c(1, 2, 3, 4, 5),
Name = c("John", "Jane", NA, "Bob", "Alice"),
Age = c(25, 30, 22, NA, 28)
)
# Step 2: Identify and count NAs in the dataframe
na_count <- colSums(is.na(df))
# Step 3: Display the count of NAs for each column
print(na_count)