Here we are explaining how to write an R program to create a list containing strings, numbers, vectors, and logical values. Here we are using a built-in function list() for this. This function helps to construct, coerce and check for both kinds of R lists. The syntax of this function is
Below are the steps used in the R program to create a list containing strings, numbers, vectors, and logical values. In this R program, we directly give the values to a built-in function list(). Here we are using variable Ldata for holding the list elements. Call the function list() for creating the list of different type values.
Ldata = list("Java", "PHP",
c(2, 4, 6, 8), TRUE, 20.19, 62.54)
print("Data of the list:")
## [1] "Data of the list:"
print(Ldata)
## [[1]]
## [1] "Java"
##
## [[2]]
## [1] "PHP"
##
## [[3]]
## [1] 2 4 6 8
##
## [[4]]
## [1] TRUE
##
## [[5]]
## [1] 20.19
##
## [[6]]
## [1] 62.54