chschulz at email.de
2012-May-22 09:23 UTC
[R] iterate over vector with "range vector" inside
Hello, Have anybody a hint, how I could iterate over the vector below. So I'll wish only 8 iterations. Put the "range vector" in c() didn't help. for(i in c(1,2,3,4,5,11:20,21:50,51:100)) { sum(dfc[i,"cnt"]) # or similar actions } Thanks in advance Christian
use 'list' instead of 'c' Sent from my iPad On May 22, 2012, at 5:23, chschulz at email.de wrote:> > Hello, > Have anybody a hint, how I could iterate over the vector below. > So I'll wish only 8 iterations. Put the "range vector" in c() didn't help. > for(i in c(1,2,3,4,5,11:20,21:50,51:http://spinroot.com/spin/Doc/Book91_PDF/x20v_1991.pdf)) { > sum(dfc[i,"cnt"]) # or similar actions > } > Thanks in advance > Christian > ______________________________________________ > R-help at 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.
Possibly Parallel Threads
- how to ignore rows missing arguments of a function when creating a function?
- Plotting survival curves after multiple imputation
- reshape -> reshape 2: function cast changed?
- code review: is it too much to ask?
- apply on logical data frame together with all (PR#6560)