w3resource

R Programming: Create a list of elements using vectors, matrices and a functions

R Programming: Basic Exercise-19 with Solution

Write a R program to create a list of elements using vectors, matrices and a functions. Print the content of the list.

Sample Solution :

R Programming Code :

l = list(
  c(1, 2, 2, 5, 7, 12),  
  month.abb,
  matrix(c(3, -8, 1, -3), nrow = 2),
  asin
)
print("Content of the list:")
print(l)

Sample Output:

[1] "Content of the list:"
[[1]]
[1]  1  2  2  5  7 12

[[2]]
 [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"

[[3]]
     [,1] [,2]
[1,]    3    1
[2,]   -8   -3

[[4]]
function (x)  .Primitive("asin")                         

R Programming Code Editor:



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a R program to create an array with three columns, three rows, and two "tables", taking two vectors as input to the array. Print the array.
Next: Write a R program to draw an empty plot and an empty plot specify the axes limits of the graphic.

Test your Python skills with w3resource's quiz

What is the difficulty level of this exercise?