The problem is that we were using a task where some subjects responded with
"1 & 2" and some responded with "2 & 4".  So there is overlap for 2 because
it means stimulus 1 for subject 1 and it means stimulus 2 for subject 2.

 subject

subject_1

1

subject_1

1

subject_1

1

subject_1

2

subject_1

2

subject_2

4

subject_2

2

subject_2

2

subject_2

4

subject_2

2

subject_2

2

subject_2

2

subject_2

4

On Fri, Aug 5, 2011 at 4:25 PM, Joshua Wiley <jwiley.ps...@gmail.com> wrote:

> Hi Edward,
>
> You can try something like:
>
> u.ppl <- unique(init.dat1$grid)
> l.ppl <- ifelse(grepl(4, init.dat1$Slide1_RESP), 2,
>                init.dat1$Slide1_RESP)
>
> Note that this is not exact as you have not provided a reproducible
> example.  I am not exactly sure how you are  putting 1 for 2 and 2 for
> 4, if the value is equal to 4, but presumably it is clearer with data.
>  In any event, look at ?ifelse it is something like a vectorized if
> statement and is, I believe, preferable to your use of a for loop.  I
> can probably give you a runnable solution if you can give the first
> few rows of the relevant data.
>
> Cheers,
>
> Josh
>
> On Fri, Aug 5, 2011 at 2:15 PM, Edward Patzelt <patze...@umn.edu> wrote:
> > I want to write code that says "If you find an element equal to 4 in this
> > vector for each person in the data set tested separately, then put in 1
> for
> > 2 and 2 for 4, else leave the variable as is"
> >
> >  u.ppl <- (unique(init.dat1$grid))
> >      l.ppl <- length(u.ppl)
> >        for (i in 1:l.ppl)
> >        {
> >          if (grep("4",init.dat1$Slide1_RESP)) {2 == 1, 4 == 2}; else
> > init.dat1$Slide1_RESP
> >
> >        }
> >
> > --
> > Edward H. Patzelt
> > Research Assistant – TRiCAM Lab
> > University of Minnesota – Psychology/Psychiatry
> > VA Medical Center
> > Office: S355 Elliot Hall - Twin Cities Campus
> > Phone: 612-626-0072  Email: patze...@umn.edu
> >
> > Please consider the environment before printing this email
> > www.psych.umn.edu/research/tricam
> >
> >        [[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.
> >
> >
>
>
>
> --
> Joshua Wiley
> Ph.D. Student, Health Psychology
> Programmer Analyst II, ATS Statistical Consulting Group
> University of California, Los Angeles
> https://joshuawiley.com/
>



-- 
Edward H. Patzelt
Research Assistant – TRiCAM Lab
University of Minnesota – Psychology/Psychiatry
VA Medical Center
Office: S355 Elliot Hall - Twin Cities Campus
Phone: 612-626-0072  Email: patze...@umn.edu

Please consider the environment before printing this email
www.psych.umn.edu/research/tricam

        [[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.

Reply via email to