【问题标题】:Names of males with height under male's median身高低于男性中位数的男性姓名
【发布时间】:2017-04-04 01:51:04
【问题描述】:

我正在尝试打印身高低于男性身高中位数的男性姓名

我通过以下命令找到了男性身高的中位数:

 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

【问题讨论】:

  • 作业什么时候交?

标签: r frame mean median


【解决方案1】:

只是子集创建一个新的数据框

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

在特定情况下,为男性过滤的数据框或添加具有中位数鉴别器的新列可能更适合进一步处理数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-09
    • 2016-09-02
    相关资源
    最近更新 更多