Exercise

Removing from a list

The natural next step is to learn how to remove elements from a list. You decide that even though Dan is your best friend, you don't want his info in your list. To remove dans_movie:

my_list$dans_movie <- NULL

my_list

$my_words
[1] "I <3 R"

$my_numbers
[1] 42 24

Using NULL is the easiest way to remove an element from your list! If your list is not named, you can also remove elements by position using my_list[1] <- NULL or my_list[[1]] <- NULL.

Instructions

100 XP
  • Take a look at your portfolio. It seems that someone has added microsoft stock that you did not buy!
  • Remove the microsoft element of portfolio using NULL.