Handling missing values (drop_na, fill)
📖 Scenario: You work as a data analyst. You have a small table of sales data, but some values are missing. You want to clean the data by removing rows with missing values and then fill missing values in another column.
🎯 Goal: Build an R script that creates a data frame with missing values, removes rows with missing values in one column, fills missing values in another column, and prints the cleaned data.
📋 What You'll Learn
Create a data frame called
sales with columns product, price, and quantity including some missing valuesCreate a variable called
cleaned_sales that removes rows with missing price using drop_na()Fill missing
quantity values in cleaned_sales using fill() from the tidyr packagePrint the final
cleaned_sales data frame💡 Why This Matters
🌍 Real World
Data cleaning is a common task in data analysis to prepare data for accurate insights.
💼 Career
Knowing how to handle missing data is essential for data analysts, scientists, and anyone working with real-world data.
Progress0 / 4 steps