Skip to content

selecting parts of a table

3 messages · emj83, Stephan Kolassa, David Winsemius

#
I have a dataframe called Match with two columns: position and tvalue.

I would like to select the parts of the dataframe that have a position> 10
but <50 and tvalues >3.5 as a new stand alone dataframe.

Could anyone help me with how to do this?

Thanks Emma
#
Hi,

new.Match <- Match[10<Match$position & Match$position<50 & 
Match$tvalues>3.5,]

Everything before the comma selects rows. You could select columns by 
using conditions after the comma.

HTH,
Stephan

emj83 schrieb:
#
Assuming that your dataframe is DF and those are names of columns then

?subset

 > DF <- data.frame(posit=runif(20, max=20), tvalues = runif(20, max=  
10))
 >
 > subset(DF, subset= posit > 10 & tvalues > 3.5 )
       posit  tvalues
4  14.66464 9.527535
6  14.71280 7.231015
9  14.76594 7.626381
10 14.05379 7.198893
11 14.23830 7.219855
12 17.47984 3.844767
13 10.95396 4.639608
15 13.21104 6.828144
19 11.75401 5.249528
20 12.95288 6.963767

.. should do the trick
On Jan 14, 2009, at 10:41 AM, emj83 wrote: