In R 4.5.2 (not before), `length<-.POSIXlt` sets "balanced" attribute of the 
result to TRUE only ifisTRUE(attr(x, "balanced")) && value <= length(x) .

For 'value' that is not a whole number, it is possible that value > length(x) 
and the length of the result is still length(x).
Instead ofvalue <= length(x) ,it is better to usevalue < length(x) + 1(not 
length(x) + 1L as length(x) may be .Machine$integer.max)orvalue - length(x) < 
1Lortrunc(value) <= length(x)orlength(r) <= length(x)orlength(r$year) <= 
length(x)(or other component of 'r').
By the way, `length<-.POSIXlt` should also use unCfillPOSIXlt(x) instead of 
unclass(x). For example, when the maximum component length is 3 and a component 
has length 1 and 'value' (the assigned length) is 2.
If unCfillPOSIXlt(x) is used and is assigned to 'x', length of any component 
can be used.
        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to