I have a data.frame as follows: a 3 a 2 a 1 b 3 b 2 c 2 c 3 c 1 c 1
Each factor (a, b, c) should be monotonically decreasing, notice that factor 'c' is not. I could use some help to figure out how to form a logical structure (mostly just syntax), that will check each 'next value' for each factor to see if it is less than the previous value. If it is less than the previous value, do nothing, else subtract 'next value' from 'current value', add that amount to the starting value and each previous value to the 'next value' is greater than 'previous value'. So basically the data.frame would look like: a 3 a 2 a 1 b 3 b 2 c 3 c 3 c 1 c 1 Thanks for your help! __________________________________ Christopher P. Peters Research Associate Center for Energy Studies http://www.enrg.lsu.edu/staff/peters Energy, Coast & Environment Building Louisiana State University Baton Rouge, LA 70803 Telephone: 225-578-4400 Fax: 225-578-4541 [[alternative HTML version deleted]] ______________________________________________ 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.