In addition to the previous answer, check this out. Note that the behavior is exactly the same as regular vectors and lists, so it cannot be called "list specific".
v <- 1:3 names(v) <- c("one", "two", "three") r <- 4:5 names(r) <- c("four", "five") (v[] <- r) four five 4 5 Warning message: In v[] <- r : number of items to replace is not a multiple of replacement length v one two three 4 5 4
Assignment through a subset saves the initial attributes (here, names). Thus, the names on the right side of the recipient are lost. Importantly, assignment through a subset follows disposal rules. In your example, all values ββare reassigned to 3, in my example, partial recirculation occurs with a warning due to incompatibility in length.
Summarizing,
- Assigning with
<- returns the estimated right side to , using the disposal rules. - This is due to disposal , since the lengths of the two objects are different.
- Without the assignment operator,
l or v essentially matches l[] or v[] .
tonytonov
source share