[R] Carrying a value down a data.frame conditionally
Pooya Lalehzari
plalehzari at platinumlp.com
Tue Dec 23 23:57:58 CET 2014
Hello,
I have a data.frame (below) containing the two fields of "Value" and "Signal" and I would need to create the third field of "To_Be_Produced". The condition for producing the third field is to carry the 1 in the "Signal" field down until "Value" is below 40.
Do I have to create a for-loop to do this or will I be able to do anything else more efficient?
df <- data.frame( Value=c(0,0,100,85,39,1,30,40,20,20,0,0),
Signal=c(0,1,0,0,0,0,0,0,0,1,0,0),
To_Be_Produced= c(0,1,1,1,0,0,0,0,0,1,0,0)
)
Thank you,
Pooya.
***
We are pleased to announce that, as of October 20th, 2014, we've moved to
our new office at:
Platinum Partners
250 West 55th Street, 14th Floor, New York, NY 10019
T: 212.582.2222 | F: 212.582.2424
***
THIS E-MAIL IS FOR THE SOLE USE OF THE INTENDED RECIPIENT(S) AND MAY CONTAIN
CONFIDENTIAL AND PRIVILEGED INFORMATION.ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE
OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, PLEASE
CONTACT THE SENDER BY REPLY E-MAIL AND DESTROY ALL COPIES OF THE ORIGINAL E-MAIL.
[[alternative HTML version deleted]]
More information about the R-help
mailing list