r - Subseting data.frames with more than 1 condition -


i found question similiar mine, need know way same thing mathematical conditions such less or equal or greator or equal (<=, >=, > or <).

subsetting dataframe in r multiple conditions

any ideas on how this?

here dput of data.frame

structure(list(cole_codigo_colegio = c(99002l, 98640l, 125211l,  3665l, 66845l, 80127l), utilidad12.2 = c(1.74224925711619e+86,  9.34905360125358e+85, 2.19766267893102e+86, 1.15601939883399e+86,  3.57148506747902e+85, 4.46252885275553e+85), genero.x = c(0.473684210526316,  0.34, 0.555555555555556, 0.529411764705882, 0.724137931034483,  0.717557251908397), matricula = c(11, 12, 11, 0, 12, 11.9541984732824 ), utilidad11.2 = c(1.08554442429751e+85, 1.23904539384648e+86,  1.41625733346334e+83, 2.98513077553705e+85, 2.85572879144527e+84,  2.62027294905256e+85), genero.y = c(0.611111111111111, 0.547945205479452,  0.333333333333333, 0.454545454545455, 0.529411764705882, 0.754545454545455 ), utilidad10.2 = c(5.29036316240969e+86, 3.60281682723794e+85,  7.98683180997873e+83, 3.69815598910933e+85, 9.03907414307155e+85,  9.93153119186974e+84), genero.x.1 = c(0.4, 0.493670886075949,  0.461538461538462, 0.571428571428571, 0.666666666666667, 0.789915966386555 ), utilidad07.2 = c(3.60312171478886e+84, 6.71597127543324e+82,  2.15239495295691e+81, 3.28836948865607e+84, 5.54815355937579e+84,  3.56877032811493e+84), genero.y.1 = c(0.625, 0.423728813559322,  0.6, 0.5, 0.631578947368421, 0.746835443037975), utilidad06.2 = c(3.2313581771241e+84,  3.60816597030472e+83, 2.28482656850331e+81, 1.6337350886429e+84,  1.581561168503e+85, 1.3090089847287e+84), genero = c(0.631578947368421,  0.53125, 0.444444444444444, 0.388888888888889, 0.5625, 1), uideal = c(2.71828182845905e+94,  2.71828182845905e+94, 2.71828182845905e+94, 2.71828182845905e+94,  2.71828182845905e+94, 2.71828182845905e+94), uprom = c(1.44190233217495e+86,  5.07702439958696e+85, 4.41422028057935e+85, 3.74713824214323e+85,  3.00650172282713e+85, 1.71274657045589e+85), genprom = c(0.54827485380117,  0.467318981022945, 0.478974358974359, 0.488854935913759, 0.622859061955091,  0.801770823175676), lnuprom = c(198.388281303249, 197.344458246354,  197.204564116063, 197.040725317712, 196.820510089025, 196.257831168032 ), lnuideal = c(217.44299874144, 217.44299874144, 217.44299874144,  217.44299874144, 217.44299874144, 217.44299874144), distancia = c(19.0547174381914,  20.0985404950863, 20.2384346253776, 20.4022734237286, 20.622488652415,  21.1851675734087)), .names = c("cole_codigo_colegio", "utilidad12.2",  "genero.x", "matricula", "utilidad11.2", "genero.y", "utilidad10.2",  "genero.x.1", "utilidad07.2", "genero.y.1", "utilidad06.2", "genero",  "uideal", "uprom", "genprom", "lnuprom", "lnuideal", "distancia" ), row.names = c(5149l, 5119l, 6631l, 230l, 3477l, 4131l), class = "data.frame") 

i want filter data-frame in way if variable "genprom"<0.5 , "matricula" >10 keep these observations (just random example).

just concatenate expressions & (and) or | (or)

using subset

 subset(df, genprom < 0.5 & matricula > 10) 

or, more safely, [

df[df[['genprom']] < 0.5 & df[['matricula']] > 10, ] 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -