在循环中进行取名后出现这样的错误:
> date_out<-function(x) {
+   n<-length(x)
+   v<-list()
+   j<-0
+   for (i in 1:n) {
+     if (length(x[[i]]<1)) next
+     p<-k[x[[i]],]
+     names(p)<-names(x[i])
+     j<-j+1
+     v[j]<-p
+   }
+   return(v)
+ }
> str(k)
'data.frame':        265 obs. of  1 variable:
 $ X: Factor w/ 265 levels "2014-03-21","2014-03-24",..: 1 2 3 4 5 6 7 8 9 10 ...
> str(b)
List of 1180
 $ X000005.SZ: int(0) 
 $ X000007.SZ: int(0) 
 $ X000008.SZ: int [1:2] 1 2
 $ X000009.SZ: int(0) 
 $ X000010.SZ: int(0) 
 $ X000011.SZ: int(0) 
 $ X000017.SZ: int(0) 
 $ X000018.SZ: int(0) 
 $ X000020.SZ: int [1:2] 2 3
 $ X000023.SZ: int(0) 
 $ X000024.SZ: int(0) 
 $ X000025.SZ: int(0) 
 $ X000029.SZ: int(0) 
> date_out(b)
Error in names(p) <- names(x[i]) : 
  'names' attribute [1] must be the same length as the vector [0]
这个是什么问题呢?不知道哪里错了,谢谢。