Hello, all.

I ran across an odd problem while working in R 2.6.0. The command line text 
follows. Basically, I attempted to convert a character vector of length 13 (in 
a data frame with 13 rows) from a character representation of dates to a POSIX 
representation using strptime. strptime returned a vector of length 9, which 
appears to contain 13 values (!) in the appropriate format.

I can't find any way to convince the strptime output that it has 13 values . . 
. even though (for example) posixvector[1:13] returns 13 values, 
anothervectorof length13<-posixvector[1:13] produces a length mismatch error.

Can anyone help diagnose this, or work around it?

Many thanks,
~Pat Carroll.


> Dataset$DateFilled
 [1] "10/20/2005" "11/4/2005"  "11/18/2005" "12/2/2005"  "4/3/2006"   
"6/5/2006"   "7/14/2006"  "4/27/2007"  "5/7/2007"   "7/17/2007"  "2/14/2005" 
[12] "2/14/2005"  "2/21/2005" 
> datefilledpos<-strptime(Dataset$DateFilled,format="%m/%d/%Y")
> datefilledpos
 [1] "2005-10-20" "2005-11-04" "2005-11-18" "2005-12-02" "2006-04-03" 
"2006-06-05" "2006-07-14" "2007-04-27" "2007-05-07" "2007-07-17" "2005-02-14"
[12] "2005-02-14" "2005-02-21"
> length(datefilledpos)
[1] 9
> length(Dataset$DateFilled)
[1] 13
> datefilledpos[1:13]
 [1] "2005-10-20" "2005-11-04" "2005-11-18" "2005-12-02" "2006-04-03" 
"2006-06-05" "2006-07-14" "2007-04-27" "2007-05-07" "2007-07-17" "2005-02-14"
[12] "2005-02-14" "2005-02-21"
> Dataset$DateFilled<-datefilledpos
Error in `$<-.data.frame`(`*tmp*`, "DateFilled", value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
> Dataset$DateFilled<-datefilledpos[1:13]
Error in `$<-.data.frame`(`*tmp*`, "DateFilled", value = list(sec = c(0,  : 
  replacement has 9 rows, data has 13
> 

 
Pat Carroll. 
what matters most is how well you walk through the fire. 
bukowski.





      
____________________________________________________________________________________
Be a better friend, newshound, and

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to