
R Language Fundamentals 35
2.5.1.0.6 Subset assignments Subset expressions can appear on the left
side of an assignment. If the subset is specified using positive indices, then
the given subset is assigned the values on the right, recycling the values if
necessary. Zero subscripts and NA subscripts are ignored.
> x[1:3] = 10
> x
, , 1
[,1] [,2] [,3]
[1,] 10 4 7
[2,] 10 5 8
[3,] 10 6 9
, , 2
[,1] [,2] [,3]
[1,] 10 13 16
[2,] 11 14 17
[3,] 12 15 18
, , 3
[,1] [,2] [,3]
[1,] 19 22 25
[2,] 20 23 26
[3,] 21 24 27
Negative subscripts can appear on the the left side of an assignment. In this
case the given subset is assigned the values on the right side of the assignment, ...