I am a new R-language user. I have set up a data frame "mydata",one of the colume of which is "skill". Now I want to select the observations whose "skill" value is equal to 1,by what command can I get it?
Here's an example: mydata<-data.frame(skill=c(1,2,3,4),x=c(1,1,1,1)) mydata[mydata$skill==1,] On Fri, Mar 27, 2009 at 16:40, minben <minbenh at gmail.com> wrote:> I am a new R-language user. I have set up a data frame "mydata",one of > the colume of which is "skill". Now I want to select the observations > whose "skill" value is equal to 1,by what command can I get it? > > ______________________________________________ > 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. >
Hi, minben wrote:> I am a new R-language user. I have set up a data frame "mydata",one of > the colume of which is "skill". Now I want to select the observations > whose "skill" value is equal to 1,by what command can I get it?Try this: mydata1<-mydatasubset(mydata, skill==1) Maybe You should also read this introduction: http://cran.r-project.org/doc/manuals/R-intro.pdf Kind regards, Kimmo
You can do like this: 1. mydata[mydata$skill==1,] 2. mydata[mydata[,"skill"]==1,] /Forin On Thu, 26 Mar 2009 23:40:32 -0700 (PDT) minben <minbenh at gmail.com> wrote:> I am a new R-language user. I have set up a data frame "mydata",one of > the colume of which is "skill". Now I want to select the observations > whose "skill" value is equal to 1,by what command can I get it? > > ______________________________________________ > 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. >-- Florin G. Maican ================================= Ph.D. candidate, Department of Economics, School of Business, Economics and Law, Gothenburg University, Sweden ----------------------------------- P.O. Box 640 SE-405 30, Gothenburg, Sweden Mobil: +46 76 235 3039 Phone: +46 31 786 4866 Fax: +46 31 786 4154 Home Page: http://maicanfg.googlepages.com/index.html E-mail: florin.maican at handels.gu.se ------------------------------------ "Not everything that counts can be counted, and not everything that can be counted counts." --- Einstein ---
minben schreef:> I am a new R-language user. I have set up a data frame "mydata",one of > the colume of which is "skill". Now I want to select the observations > whose "skill" value is equal to 1,by what command can I get it? > > ______________________________________________ > 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. >To add the number of possibilities :): subset(mydata, skill == 1) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul