[R] loop through columns in a data frame

Yuan, Keming (CDC/DDNID/NCIPC/DVP) vrm4 @end|ng |rom cdc@gov
Mon Mar 25 17:10:18 CET 2019


Hi All,

I have a data frame with variable names like A_le, A_me, B_le, B_me, C_le, C_me....
if A_le=1 or A_me=1 then  I need to create a new column A_new=1. Same operation to create columns B_new, C_new...
Does anyone know how to use loop (or other methods) to create new columns? In SAS, I can use array to get it done. But I don't know how to do it in R.

Thanks,

Keming Yuan
CDC


	[[alternative HTML version deleted]]



More information about the R-help mailing list