I am extremely puzzled by this behavior in R. I have a data frame called Trials in which I have results from an experiment. I am trying to do a subjects analysis, but getting weird results. Each row has 1 trial in it, which includes a column for the subject number I get the list of subject numbers like so: > Subj=unique(sort(Trials$Subj)) Then I loop over them. But I get strange results. As a test, I tried the following: > i=1 > Subj[i] [1] 49 > thisSubj = subset(Trials,Trials$Subj==Subj[i]) > thisSubj$Ansr[1] [1] "abacus" > thisSubj = subset(Trials,Trials$Subj==49) > thisSubj$Ansr[1] [1] "able"
I am expecting to get a result of "able" both times, since I know that Subj[i] is 49, when i=1. Clearly the two different "thisSubj=..." lines are not returning the same values, as I would expect them to. Is this the normal and correct behavior for R, or am I missing something? And if it is normal and correct, what do I need to do to get the behavior I am expecting. Thanks in advance for any advice. Rob -- Robert Felty http://robfelty.com "In this house we obey the laws of thermodynamics!" -- Homer Simpson ______________________________________________ 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.