请看下面:
x=c("2006/10/6","2006/10/7","2006/11/2","2006/11/8")
> x=strptime(x,format="%Y/%m/%d")
> y=c("zs","zs","ls","ls")
> r=c(0.12,0.45,-0.2,0.05)
> z=data.frame(x,y,r)
> z
x y r
1 2006-10-06 zs 0.12
2 2006-10-07 zs 0.45
3 2006-11-02 ls -0.20
4 2006-11-08 ls 0.05
> which(z$x=="2006-10-07"&z$y=="zs")
integer(0)
问题出在X的格式上,若
xx=c("2006/10/6","2006/10/7","2006/11/2","2006/11/8")
>
> y=c("zs","zs","ls","ls")
> r=c(0.12,0.45,-0.2,0.05)
> z=data.frame(xx,y,r)
> which(xx=="2006-10-07"&y=="zs")
>2
成功!问题解决.
但xx=="2006-10-07"有什么问题呢?