Q:

Write a R program to extract all elements except the third element of the first vector of a given list

0

Write a R program to extract all elements except the third element of the first vector of a given list.

Sample list: (g1 = 1:10, g2 = "R Programming", g3 = "HTML")

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

list1 = list(g1 = 1:10, g2 = "R Programming", g3 = "HTML")
print("Original list:")
print(list1)
print("First vector:")
print(list1$g1)
print("First vector without third element:")
list1$g1 = list1$g1[-3]
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] "First vector:"
 [1]  1  2  3  4  5  6  7  8  9 10
[1] "First vector without third element:"
[1]  1  2  4  5  6  7  8  9 10

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now