名称

2016-11-20 47 views
0

我试图打印,男性的身高平均名称

我发现男性的身高用下面的命令中位数之下具有高度的男性的名字:

y1<-median(ex1[which(ex1$gender=='male') 

,我试图打印这样的名字:

if (gender=='male') 
{ 
    if (height<y1) 
    print(Names) 

} 

有人能帮助我吗?谢谢:)

文本文件:

 Names height Shoesize gender Location 
    1 andreas 181  44 male citycenter 
    4  maria 170  43 female citycenter 
    5 xristina 172  43 female citycenter 
    13 nikos 175  42 male outofcity 
    14 kostas 181  44 male outofcity 
    15 giannis 180  43 male outofcity 
    16 eleni 177  43 female outofcity 
    17 panos 133  41 male outofcity 
+1

作业何时到期? –

+0

十一月十八日 –

+0

任何你不接受答案的理由? – eckes

回答

0

刚子集或创建一个新的数据帧

ex1.medheight <- median(ex1$height[ex1$gender=="male"]) 
ex1.shortmales <- ex1[(ex1$height < ex1.medheight && ex1$gender == "male"),] 

在特定的情况下,过滤男性的数据帧或添加有位disciminator新列可能会更好地进一步处理数据。