LoslegenKostenlos loslegen

Using replace_with_na

Following on from the previous dataset, we now know that we have a few strange missing values.

Now, we are going to do something about it, and replace these values with missings (e.g. NA) using the function replace_with_na().

Diese Übung ist Teil des Kurses

Dealing With Missing Data in R

Kurs anzeigen

Anleitung zur Übung

For the pacman dataset:

  • Using replace_with_na(), replace missing values "N/A", "na", and "missing" with NA for the year, and score variables.
  • Test to see if you have removed all the missing values using miss_scan_count() at the end.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Print the top of the pacman data using `head()`
head(___)

# Replace the strange missing values "N/A", "na", and  
# "missing" with `NA` for the variables, year, and score
pacman_clean <- replace_with_na(_____, replace = list(year = c(___, ___, ___),
                                score = c(___, ___, ___)))
                                        
# Test if `pacman_clean` still has these values in it?
miss_scan_count(____, search = list(___, ___, ___))
Code bearbeiten und ausführen