【发布时间】:2015-12-23 03:06:27
【问题描述】:
我对使用R 非常陌生。我正在尝试用数据集做一些基本的事情。我有一个只有一列 (date) 的数据集,其中包含参与者填写调查的日期:
11/11/2015
11/11/2015
11/11/2015
11/11/2015
11/11/2015
11/11/2015
11/11/2015
11/11/2015
27/11/2015
27/11/2015
etc (there are about 180 more responses)
到目前为止我已经完成了:
NUdates <- nrow(unique(date))
这表明我有 12 个基于响应的唯一日期
接下来我要做的就是只返回最早和最晚的日期,这样我就会有对象:
Emonth # (this would be the earliest month that a participant filled out the survey)
Lmonth # (this would be the latest month that a participant filled out he survey)
Year # (this would be the year the surveys were filled out)
然后使用降价我可以说:
参与者在
r (Emonth)和r (Lmonth)之间的r (NUdates)天完成了r (year)的调查。
【问题讨论】:
-
我怀疑
?range函数会在这里剪掉它。你试过?min或?max吗? -
Nope
range函数不起作用,至少在日期格式中不起作用,minmax也不起作用,原因相同:FUN(X[[i ]], ...) : 仅在具有所有数值变量的数据框上定义 -
尝试用 as.date 包裹它。看我可以帮你解决你的问题,但你需要为我们提供一个可重现的例子。我们没有时间在这里猜测您的数据并手动创建变量。所以在你问问题之前,请阅读规则。
-
函数名是
as.Date
标签: r r-markdown