w3resource

R Programming: Create a list containing strings, numbers, vectors and a logical values

R Programming: List Exercise-1 with Solution

Write a R program to create a list containing strings, numbers, vectors and a logical values.

Sample Solution :

R Programming Code :

list_data = list("Python", "PHP", c(5, 7, 9, 11), TRUE, 125.17, 75.83)
print("Data of the list:")
print(list_data)

Sample Output:

[1] "Data of the list:"
[[1]]
[1] "Python"

[[2]]
[1] "PHP"

[[3]]
[1]  5  7  9 11

[[4]]
[1] TRUE

[[5]]
[1] 125.17

[[6]]
[1] 75.83                         

R Programming Code Editor:



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

Previous: R Programming Exercises Home.
Next: Write a R program to list containing a vector, a matrix and a list and give names to the elements in the list.

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.