Complete the code to remove rows with missing values from the data frame.
clean_data <- [1](data)fill_na which is not a function to drop rows.na.omit which works but is base R, not tidyverse.The drop_na() function removes rows with missing values from a data frame.
Complete the code to replace missing values in the 'score' column with 0.
data$score <- [1](data$score, 0)
drop_na which removes rows instead of replacing values.fill_na which is not a base or tidyverse function.The replace_na() function replaces missing values with a specified value.
Fix the error in the code to fill missing values in the 'age' column with the previous non-missing value.
library(tidyr) data <- [1](data, age, .direction = "down")
replace_na which replaces with a fixed value, not previous values.drop_na which removes rows instead of filling.The fill() function from tidyr fills missing values using the previous non-missing value when direction is "down".
Fill both blanks to create a new data frame without missing values and then replace missing values in 'height' with 170.
clean_data <- data %>% [1]() %>% mutate(height = [2](height, 170))
fill() instead of replace_na() to replace values.na.omit inside the pipe which is less common.First, drop_na() removes rows with missing values, then replace_na() replaces missing 'height' values with 170.
Fill all three blanks to create a dictionary of counts for non-missing 'category' values, filtering out categories with zero count.
counts <- table(data$category) %>% as.data.frame() %>% filter(Freq [1] 0) %>% mutate(category = as.character([2]), count = [3])
< instead of > in filter condition.The code filters categories with frequency greater than 0, converts category to character, and assigns frequency to count.