[R] Conditional variable assignment
mhosack at state.pa.us
Tue Mar 16 20:44:09 CET 2010
Once again I am stuck with a problem I can't seem to figure out. I suppose this learning curve levels off eventually, lol. I am learning on my own with absolutely no background in programming, so if I seem to request help a lot it's not because I am seeking others to do the work for me. I need to assign one of two arrival times to the 'ARRIVE' variable of my dataframe, and I want a value assigned only to the first element of each 'MM' by 'DD' variable grouping. The value used (either 0700 or 1430) will be conditional on the value in the 'TOD' variable, such that if 'TOD' == 1, 'ARRIVE'<-0700, and if 'TOD'==2, 'ARRIVE'<-1430. I want the remaining three 'MM' by 'DD' values for each unique grouping to remain "NA" for now, because I intend to calculate them later. I have tried ifelse statements with ddply, for loops, etc. to no avail. Any help would be greatly appreciated.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 85978 bytes
More information about the R-help