Hi JL, How about the following?
rowSums(d >1) # d is your data Best, Jorge.- On Thu, Nov 10, 2011 at 10:24 AM, JL Villanueva <> wrote: > Hi, > > I am a little new in R but I'm finding it extremely useful :) > > Here's my tiny question: > > I've got a table with a lot of columns. What I am interested now is to > evaluate how many of 4 columns have a value greater than 1. > I think it can be done with subset() but it will take a very long condition > and become unfeasible if I want to compare more than 4 columns. > > I put here a small example > > Col1 Col2 Col3 Col 4 > 1 1 1 1 <-0 columns greater than 1 > 2 1 1 1 <-1 column greater than 1 > 4 1 4 1 <-2 columns greater than 1 > 3 3 3 3 <-3 columns greater than 1 > > Then I want to filter by that number, my idea is to create a new column > storing the number calculated and subset() by it. > > Any hints? > Thanks in advance > > JL > > [[alternative HTML version deleted]] > > ______________________________________________ > 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]] ______________________________________________ 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.