I want to clearly understand difference between [] and [[]] and I ran below snippet of code. I know that [[]] returns a individual member of list while [] returns list of elements. But then why do i get an error when I run "all_data[1]=list(5,6)" but no error when I run "all_data[[1]]=list(5,6)" or when I run "all_data[2]=5"
all_data <- list()
all_data[2]=5
all_data[1]=list(5,6)
all_data[[1]]=list(5,6)
all_data
as per the fist comment of the first answer, adding a line of a code which helps to understand further
all_data[1:2] <- list(5,6)