This R program helps you to create a list of multiple datatype values. For a better understanding of lists, you can visit our page here
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
list(…) #Where … indicates objects, possibly named.
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.
STEP 1: Assign variables Ldata with a list of values
STEP 2: Call the function list as list() with different types of values
STEP 3: print the variable Ldata which holding different lists
Ldata = list("Java", "PHP", c(2, 4, 6, 8), TRUE, 20.19, 62.54) print("Data of the list:") print(Ldata)
 "Data of the list:" []  "Java" []  "PHP" []  2 4 6 8 []  TRUE []  20.19 [] 62.54