[R] Seeking help with a loop

From: Greg Blevins <GBLEVINS_at_marketsolutionsgroup.com>
Date: Thu 04 Aug 2005 - 00:09:31 EST

Hello R Helpers,

After spending considerable time attempting to write a loop (and searching the help archives) I have decided to post my problem.

In a dataframe I have columns labeled:

q33a q33b q33c...q33r q35a q35b q35c...q35r

What I want to do is create new variables based on the following logic: newfielda <- ifelse(q35a==1, q33a, NA)
newfieldb <- ifelse(q35b==1, q33b, NA)

What I did was create two new dataframes, one containing q33a-r the other q35a-r and tried to loop over both, but I could not get any of the loop syntax I tried to give me the result I was seeking.

Any help would be much appreciated.

Greg Blevins
The Market Solutions Group, Inc.
Minneapolis, MN

Windows XP, R 2.1.1

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Aug 04 00:16:36 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:39 EST