Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Introduction to lists
Accessing list elements
Unnamed lists
Working with lists
23. Deleting a member from a list
Summary

Instruction

Awesome, that's correct! What about removing unnecessary members from a list?

Suppose we want to remove the profession member from the candidate list. This member isn't really needed, since we can derive the same information from the prior_working_experience member if we assume that candidates list all the roles they held in their previous and current jobs.

We can remove this member like so:

candidate$profession <- NULL
Basically, by assigning NULL to a specific list member, we tell R to completely remove that member from the list. Of course, we'd achieve the same result if we were to use
candidate[["profession"]] <- NULL
or
candidate[[4]] <- NULL

Exercise

Run the code. Then, uncomment the first line (remove the # from #candidate$profession <- NULL) and run the code again. Notice that the profession member no longer exists.