[R] loop for in and decimals
David Winsemius
dwinsemius at comcast.net
Fri May 21 20:46:54 CEST 2010
On May 21, 2010, at 2:18 PM, Robert U wrote:
> Dear R-users,
>
> I'm trying to make the following loop: for (x in 0 : 10) and i would
> like x to be decimals rather than integers, giving a x range of e.g.
> 0.0 0.1 0.2 0.3 ... 9.9, 10. Would anyone know how to do that ?
>
> with regards,
Had you not been aware of the seq function, as mentioned by others,
you could also have used:
for (i in 1:100/10) {
hey[i] <- diddle(dee[i])
}
Because ":" has higher precedence, you would not need to enclose the
sequence in parens. This precedence rule is sometimes the source of
confusion and I believe there is a FAQ item based on that source of
confusion.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list