Skip to content
Prev 316827 / 398506 Next

If() values in one dataframe then return values from another

On Feb 4, 2013, at 9:48 AM, Steven Ranney wrote:

            
One hopes for the success of htis effort that 'data1' has an equal number of rows.
Generally sequential testing is best handled with `ifelse` rather than with for loops and `if () {} else{}`

mA <- ifelse ( apply(data, 1,  any),  meter, NA)
The fact that you have constructed a factor variable suggest that you made an error in building the 'meter' data and that is it no numeric at the moment. The fact that it is only length = 1 is due to your not indexing the construction of 'mA' in your loop.
David Winsemius
Alameda, CA, USA