[R] Help with a problem
Michael Hess
mlhess at med.umich.edu
Sat Jul 17 20:10:44 CEST 2010
Hello R users,
I am a researcher at the University of Michigan looking for a solution to an R problem. I have loaded my data in from a mysql database and it looks like this
> data
ds c1 c2
1 2010-04-03 100 0
2 2010-04-30 11141 15
3 2010-05-01 3 16
4 2010-05-02 7615 14
5 2010-05-03 6910 17
6 2010-05-04 5035 3
7 2010-05-05 3007 15
8 2010-05-06 4 14
9 2010-05-07 8335 17
10 2010-05-08 2897 13
11 2010-05-09 6377 17
12 2010-05-10 3177 17
13 2010-05-11 7946 15
14 2010-05-12 8705 0
15 2010-05-13 9030 16
16 2010-05-14 8682 16
17 2010-05-15 8440 15
What I am trying to do is sort by ds, and take rows 1,7, see if c1 is at least 100 AND c2 is at least 8. If it is not, start with check rows 2,8 and if not there 3,9....until it loops over the entire file. If it finds a set that matches, set a new variable equal to 1, if never finds a match, set it equal to 0.
I have done this in stata but on this project we are trying to use R. Is this something that can be done in R, if so, could someone point me in the correct direction.
Thanks,
Michael Hess
University of Michigan
Health System
**********************************************************
Electronic Mail is not secure, may not be read every day, and should not be used for urgent or sensitive issues
More information about the R-help
mailing list