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 ?

Please start new threads when you have a new question, do not reply to existing threads and change the subject.

1) Use the seq function for what you want to do.

 seq(0, 10, by = 0.1)

In fact, according to ?colon,

For numeric arguments ‘from:to’ is equivalent to ‘seq(from, to)’,
     and generates a sequence from ‘from’ to ‘to’ in steps of ‘1’ or
     ‘1-’.  Value ‘to’ will be included if it differs from ‘from’ by an
     integer up to a numeric fuzz of about ‘1e-7’.

2) Perhaps you can avoid a for loop by using apply/sapply functions

3) Watch out for FAQ 7.31 depending on what you're doing with the values seq produces.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to