【发布时间】:2014-01-20 07:30:15
【问题描述】:
这是我的功能:
x<-read.table(....., stringsAsFactors=FALSE, header=T);
x;
Timestamp time Barcode
1 11/1/2013 8:25 M01.A
2 11/1/2013 8:25 M01.B
3 11/1/2013 8:43 M02.A
4 11/1/2013 8:43 M02.B
5 11/1/2013 9:03 M03.A
6 11/1/2013 9:03 M03.B
7 11/1/2013 9:18 M04.A
8 11/1/2013 9:18 M04.B
dput(head(x));
structure(list(Timestamp = c("11/1/2013", "11/1/2013", "11/1/2013",
"11/1/2013", "11/1/2013", "11/1/2013"), time = c("8:25", "8:25",
"8:43", "8:43", "9:03", "9:03"), Barcode = c("M01.A", "M01.B",
"M02.A", "M02.B", "M03.A", "M03.B")), .Names = c("Timestamp",
"time", "Barcode"), row.names = c(NA, 6L), class = "data.frame")
target<- x$Timestamp;
t<- strptime(x$Timestamp, format = "%m/%d/%Y");
t;
[1] "2013-11-01" "2013-11-01" "2013-11-01" "2013-11-01" "2013-11-01" "2013-11-01" "2013-11-01" "2013-11-01"
for (i in seq_along(target)){
x$Timestamp[x$Timestamp == target[i]]<- t[i]
};
我正在尝试使用 strptime 来隐藏日期,并且它有效,现在我正在尝试获取此索引向量并替换此列 x$Timestamp。谁能告诉我我做错了什么?我只是没看到。
这是我得到的错误:
$<-.data.frame(*tmp*, "Timestamp", value = list(sec = c(0, :
替换有9行,数据有78
【问题讨论】: