Re: [R] inconsistent output when using variable substitution

From: Robert Felty <robfelty_at_indiana.edu>
Date: Fri, 30 May 2008 18:31:48 -0400

Duncan, Mark, et al.,
> It's a scoping problem. To be helpful, subset looks up variables within
> the dataframe first. Since it can find Subj there, that's the one it
> uses in the test.
>
> The easiest solution is just to make sure that Subj is named something
> that isn't a column of Trials, e.g. localSubj. Then you could use
>
> subset(Trials, Subj == localSubj[1])

This works perfectly, as does

> thisSubj <- Trials[Trials$Subj == Subj[1], ]

I had tried the latter method awhile ago when I was first learning, but I had been missing the final comma, and had come to the conclusion that this method only worked when selecting a particular column of a data frame. Now I know better. Thanks so much for everyone's help. I am very impressed by the R community!!!!

Rob

--
Robert Felty
http://robfelty.com

"nunc est bibendum" 
  -- Horace, Ode 37

______________________________________________
R-help_at_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.
Received on Mon 02 Jun 2008 - 04:13:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 02 Jun 2008 - 04:30:37 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive