ComeçarComece de graça

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.

Este exercício faz parte do curso

Introduction to R for Finance

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Take a look at portfolio


# Remove the microsoft stock prices from your portfolio
Editar e executar o código