Зміст курсу
R Introduction: Part II
R Introduction: Part II
Modifying
Now let's move on to list modification tools. First, let's consider methods of adding an element (or elements) to a list.
The first method is convenient for adding single values. You need to assign a new value to the new index or naming. For example, let's add a new element named integer
with the value of 23L
.
Note
Unlike in the
list()
function, you must use quotes for naming while adding a new element. You can also 'merge' two lists by placing them inside a vector. This approach will 'connect' two lists together.
Also, you can delete elements from the list. To do it, assign to the necessary index value NULL
. For example, let's remove TRUE
from the first example.
As you can see, you removed the TRUE
element. Finally, to change the existing value of the list, reassign the new value to the existing index/naming. For example, if you write test[1] <- "word"
, then instead of "Text"
, the first element will be "word"
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.
Все було зрозуміло?
Modifying
Now let's move on to list modification tools. First, let's consider methods of adding an element (or elements) to a list.
The first method is convenient for adding single values. You need to assign a new value to the new index or naming. For example, let's add a new element named integer
with the value of 23L
.
Note
Unlike in the
list()
function, you must use quotes for naming while adding a new element. You can also 'merge' two lists by placing them inside a vector. This approach will 'connect' two lists together.
Also, you can delete elements from the list. To do it, assign to the necessary index value NULL
. For example, let's remove TRUE
from the first example.
As you can see, you removed the TRUE
element. Finally, to change the existing value of the list, reassign the new value to the existing index/naming. For example, if you write test[1] <- "word"
, then instead of "Text"
, the first element will be "word"
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.
Все було зрозуміло?
Now let's move on to list modification tools. First, let's consider methods of adding an element (or elements) to a list.
The first method is convenient for adding single values. You need to assign a new value to the new index or naming. For example, let's add a new element named integer
with the value of 23L
.
Note
Unlike in the
list()
function, you must use quotes for naming while adding a new element. You can also 'merge' two lists by placing them inside a vector. This approach will 'connect' two lists together.
Also, you can delete elements from the list. To do it, assign to the necessary index value NULL
. For example, let's remove TRUE
from the first example.
As you can see, you removed the TRUE
element. Finally, to change the existing value of the list, reassign the new value to the existing index/naming. For example, if you write test[1] <- "word"
, then instead of "Text"
, the first element will be "word"
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.
Modifying
Now let's move on to list modification tools. First, let's consider methods of adding an element (or elements) to a list.
The first method is convenient for adding single values. You need to assign a new value to the new index or naming. For example, let's add a new element named integer
with the value of 23L
.
Note
Unlike in the
list()
function, you must use quotes for naming while adding a new element. You can also 'merge' two lists by placing them inside a vector. This approach will 'connect' two lists together.
Also, you can delete elements from the list. To do it, assign to the necessary index value NULL
. For example, let's remove TRUE
from the first example.
As you can see, you removed the TRUE
element. Finally, to change the existing value of the list, reassign the new value to the existing index/naming. For example, if you write test[1] <- "word"
, then instead of "Text"
, the first element will be "word"
.
Завдання
Given list info
from the previous chapter. Your tasks are:
- Rewrite the fourth element to
44
(this chapter is the 44th). - Remove the third element (which is
1
). - Add a new element named
Level
with the value of'Beginner'
. - Output modified list
info
.