You are doing it in your bit about 1:10, which is shorthand for
generating a sequence 1, 2, 3, ..., 9, 10. Use ?seq to do what you
want.
for(i in seq(1, 10, by = 2))
cat(i, "\n")
Best,
Erik
Nair, Murlidharan T wrote:
How do I define the incremental step in a "for" loop?
for (j in 1:10){
How do I define the incremental step in a "for" loop?
for (j in 1:10){
cat(j, "\n")
}
In the above example, if I want to increment j by 2 where do I specify that?
Thanks
[[alternative HTML version deleted]]
__
R-help@r-project.org mail
2 matches
Mail list logo