R中的时间轴错误:“分钟”对各种因素没有意义

问题描述 投票:0回答:1

我的原始数据集

df

   bugid           timestamp                    commenter     Owner.
1  18348 2011-07-10 12:26:00        [email protected]     No
2  18348 2011-07-11 10:47:16 ralf%[email protected]     No
3  18348 2011-07-11 17:44:50           [email protected]    Yes
4  18348 2011-07-11 18:13:17             [email protected]     No
5  18348 2011-07-11 18:14:39        [email protected]     No
6  18348 2011-07-11 18:23:54        [email protected]     No
7  18348 2011-07-13 14:36:31           [email protected]     No
8  18348 2011-07-15 18:16:12           [email protected]    Yes
9  18348 2011-07-15 18:17:54           [email protected]    Yes
10 18348 2011-07-26 06:35:04           [email protected]     No
11 18348 2011-09-04 21:34:03        [email protected]     No
12 18348 2011-09-13 23:14:20           [email protected]    Yes
13 18348 2011-10-19 18:49:22             [email protected]     No

dput(df)

structure(list(bugid = c(18348L, 18348L, 18348L, 18348L, 18348L, 
18348L, 18348L, 18348L, 18348L, 18348L, 18348L, 18348L, 18348L
), timestamp = structure(1:13, .Label = c("2011-07-10 12:26:00", 
"2011-07-11 10:47:16", "2011-07-11 17:44:50", "2011-07-11 18:13:17", 
"2011-07-11 18:14:39", "2011-07-11 18:23:54", "2011-07-13 14:36:31", 
"2011-07-15 18:16:12", "2011-07-15 18:17:54", "2011-07-26 06:35:04", 
"2011-09-04 21:34:03", "2011-09-13 23:14:20", "2011-10-19 18:49:22"
), class = "factor"), commenter = structure(c(4L, 5L, 6L, 3L, 
4L, 4L, 7L, 6L, 6L, 2L, 1L, 6L, 8L), .Label = c("[email protected]", 
"[email protected]", "[email protected]", "[email protected]", 
"ralf%[email protected]", "[email protected]", "[email protected]", 
"[email protected]"), class = "factor"), Owner. = structure(c(1L, 
1L, 2L, 1L, 1L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 1L), .Label = c("No", 
"Yes"), class = "factor")), class = "data.frame", row.names = c(NA, 
-13L))

然后执行以下操作:

df$date <- as.Date(df$timestamp)

数据集因此变为:

df
   bugid           timestamp                    commenter Owner.       date
1  18348 2011-07-10 12:26:00        [email protected]     No 2011-07-10
2  18348 2011-07-11 10:47:16 ralf%[email protected]     No 2011-07-11
3  18348 2011-07-11 17:44:50           [email protected]    Yes 2011-07-11
4  18348 2011-07-11 18:13:17             [email protected]     No 2011-07-11
5  18348 2011-07-11 18:14:39        [email protected]     No 2011-07-11
6  18348 2011-07-11 18:23:54        [email protected]     No 2011-07-11
7  18348 2011-07-13 14:36:31           [email protected]     No 2011-07-13
8  18348 2011-07-15 18:16:12           [email protected]    Yes 2011-07-15
9  18348 2011-07-15 18:17:54           [email protected]    Yes 2011-07-15
10 18348 2011-07-26 06:35:04           [email protected]     No 2011-07-26
11 18348 2011-09-04 21:34:03        [email protected]     No 2011-09-04
12 18348 2011-09-13 23:14:20           [email protected]    Yes 2011-09-13
13 18348 2011-10-19 18:49:22             [email protected]     No 2011-10-19

我删除了timestamp列,认为该列必定会引起问题:

remove.cols = names(df) %in% c("timestamp")
df.pruned <- df[!remove.cols]

但是,当我尝试使用以下方法生成时间轴时:

timelineS(df.pruned)

我收到错误:

Summary.factor(c(4L,5L,6L,3L,4L,4L,7L,6L,6L,2L,1L,:“分钟”对因素没有意义

在类似的问题上阅读主题后,尝试将日期字段转换为数字。但是似乎没有什么可以解决问题。请帮助。

r timeline
1个回答
0
投票
timelineS软件包的文档指出,您为timelineS函数提供的数据框只能由两列组成-一列用于事件,一列用于日期:
© www.soinside.com 2019 - 2024. All rights reserved.