Re: [R] Selecting rows and columns of a data frame using relational operators

2017-03-02 Thread Tunga Kantarcı
Thank you for all the helpful answers. Tunga __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

[R] Selecting rows and columns of a data frame using relational operators

2017-03-02 Thread Tunga Kantarcı
Thank you for all the helpful answers. Tunga __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread PIKAL Petr
ons > Sent: Monday, February 27, 2017 1:30 PM > To: Tunga Kantarcı <tungakanta...@gmail.com> > Cc: R-help <r-help@r-project.org> > Subject: Re: [R] Selecting rows and columns of a data frame using relational > operators > > The answer is simple > > dat

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Erich Subscriptions
The answer is simple data[,4] == 1 produces a logical vector of length nrow(data) and the subsetting mechanism for data frames in R needs a vector of the same length as the data frame has rows. data[1:20,4] == 1 produces a data frame of length 20, and if this is not the length of data. So R

Re: [R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Ulrik Stervbo
Hi Tunga, The function subset() is probably what you are looking for. You might also want to look at a tutorial to understand the R syntax. In addition, calling your data data is not a good idea because of the name clash with the function data(). Hope this helps, Ulrik On Mon, 27 Feb 2017 at

[R] Selecting rows and columns of a data frame using relational operators

2017-02-27 Thread Tunga Kantarcı
Consider a data frame named data. data contains 4 columns and 1000 rows. Say the aim is to bring together columns 1, 2, and 4, if the values in column 4 is equal to 1. We could use the syntax data(data[,4] == 1, c(1 2 4)) for this purpose. Suppose now that the aim is to bring together columns 1,