Readers, For a data set: text1,23,text2,45 text1,23,text3,78 text1,23,text3,56 text1,23,text2,45 The following command was entered: datasubset<-data.frame(dataset[,3]=="text3") The result of datasubset is TRUE TRUE The required result is text1,23,text3,78 text1,23,text3,56 What is the correct command to use please? Thanks in advance.
Try using which() Something like data.frame(dataset[which(dataset[,3]=="text3"),]) e-letter wrote:> > Readers, > > For a data set: > > text1,23,text2,45 > text1,23,text3,78 > text1,23,text3,56 > text1,23,text2,45 > > The following command was entered: > > datasubset<-data.frame(dataset[,3]=="text3") > > The result of > > datasubset > > is > > TRUE > TRUE > > The required result is > > text1,23,text3,78 > text1,23,text3,56 > > What is the correct command to use please? > > Thanks in advance. > > ______________________________________________ > 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. >-- View this message in context: http://r.789695.n4.nabble.com/create-data-set-from-selection-of-rows-tp3356866p3356879.html Sent from the R help mailing list archive at Nabble.com.
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20110315/620deba2/attachment.pl>
Hi, What you are after is: datasubset <- dataset[ dataset[,3] == "text3", ] Equivalently, you can use: datasubset <- subset(dataset, subset = dataset[,3] == "text3") HTH, Francisco On Tue, Mar 15, 2011 at 3:09 PM, e-letter <inpost@gmail.com> wrote:> Readers, > > For a data set: > > text1,23,text2,45 > text1,23,text3,78 > text1,23,text3,56 > text1,23,text2,45 > > The following command was entered: > > datasubset<-data.frame(dataset[,3]=="text3") > > The result of > > datasubset > > is > > TRUE > TRUE > > The required result is > > text1,23,text3,78 > text1,23,text3,56 > > What is the correct command to use please? > > Thanks in advance. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]