Write a R program to Add 10 to each element of the first vector in a given list.
Sample list: (g1 = 1:10, g2 = "R Programming", g3 = "HTML")
list1 = list(g1 = 1:10, g2 = "R Programming", g3 = "HTML") print("Original list:") print(list1) print("New list:") list1$g1 = list1$g1 + 10 print(list1$g1)
Sample Output:
[1] "Original list:" $g1 [1] 1 2 3 4 5 6 7 8 9 10 $g2 [1] "R Programming" $g3 [1] "HTML" [1] "New list:" [1] 11 12 13 14 15 16 17 18 19 20
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer