R_Prac-6.r
Problem Statement
R_Prac-6.r
Program to access List elements, modify a List Element, add items to List, Remove items from a List, length of List.
Source Code
r
# Program to access List elements, modify a List Element, add items to List,
# Remove items from a List, length of List.
l <- list("Amit", 19, "Madhyamgram", 94.5)
print("Initial list:")
print(l)
l[[4]] = 95.46
print("after modifing last element: ")
print(l)
l[length(l) + 1] <- "hello"
print("after adding new element:")
print(l)
l[3] <- NULL
print("after deleting a element: ")
print(l)
print(paste("length of the list after modifing:", length(l)))1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20