I have two vectors "data1" and "data2". I want to create a list of these two vectors. But when I create a list of these two vectors I want the names of the variables in the list to be "$data1" and "$data2" instead of [[1]] and [[2]]. Below is the code for better understanding:
data1 <- c(3,4,5,6,7)
data2 <- c(8,9,10,11)
datalist <- list(data1,data2)
The output is:
datalist
# [[1]]
# [1] 3 4 5 6 7
# [[2]]
# [1] 8 9 10 11
Instead I want this to be the output without actually setting the names myself. Is there any way the names of the variables in the list get set automatically.
datalist
# $data1
# [1] 3 4 5 6 7
# $data2
# [1] 8 9 10 11