如何只挑选某些数据
How to pick only certain data
我只想为每个 人获取 x 和 x-date 列中的数据。
(条件是 x-date 介于 day1 和 day2 列,每个 person)。请看下图
例如,
a, x=111, x-date=2/2/2016
b, x=8990, x-dates=2/3/2016
c, x=333, x-dates=5/5/2011
如果我答对了你的问题,并且你所有的日期都是日期格式,你可能会做类似的事情:
基础 R :
df[(df$x-date > df$day1 & df$x-date < df$day2), c('person', 'x', 'x-date')]
你可以使用子集函数。
subset(df, x==111 & x-date=='2/2/2016', select = c(person,x,x-date))
我只想为每个 人获取 x 和 x-date 列中的数据。 (条件是 x-date 介于 day1 和 day2 列,每个 person)。请看下图
例如,
a, x=111, x-date=2/2/2016
b, x=8990, x-dates=2/3/2016
c, x=333, x-dates=5/5/2011
如果我答对了你的问题,并且你所有的日期都是日期格式,你可能会做类似的事情:
基础 R :
df[(df$x-date > df$day1 & df$x-date < df$day2), c('person', 'x', 'x-date')]
你可以使用子集函数。
subset(df, x==111 & x-date=='2/2/2016', select = c(person,x,x-date))