Dear R-list, I'm experiencing some problems while using "strptime", which I don't understand.> str(natver)'data.frame': 154 obs. of 8 variables: $ ID : Factor w/ 14 levels "AC","ALS","FA",..: 10 11 9 1 4 8 13 3 14 12 ... $ CdBMin : int 22 22 26 26 28 23 27 23 25 26 ... $ CdBMax : int 22 24 27 26 32 26 29 30 29 28 ... $ Hrend : int 184 NA 120 168 NA 152 165 160 140 140 ... $ Age : int 28 32 44 21 35 47 36 29 36 43 ... $ Weight : int 63 70 80 57 69 74 82 71 85 70 ... $ variable: Factor w/ 11 levels "X50","X100","X150",..: 1 1 1 1 1 1 1 1 1 1 ... $ value : Factor w/ 47 levels "00:00:36","00:00:39",..: 1 2 4 3 3 4 5 7 8 6 ...> > head(natver)ID CdBMin CdBMax Hrend Age Weight variable value 1 PHu 22 22 184 28 63 X50 00:00:36 2 PK 22 24 NA 32 70 X50 00:00:39 3 PH 26 27 120 44 80 X50 00:00:46 4 AC 26 26 168 21 57 X50 00:00:42 5 FT 28 32 NA 35 69 X50 00:00:42 6 OA 23 26 152 47 74 X50 00:00:46> > natver$Time<-strptime(natver$value, format="%d/%m/%Y %H:%M:%S")Erreur dans `$<-.data.frame`(`*tmp*`, "Time", value = list(sec = c(NA_real_, : le tableau de remplacement a 9 lignes, le tableau remplacé en a 154 Do you what's wrong there ? I'm working with R-2.5.0, under Windows 2000. Thanks for your help, Best regards, François [[alternative HTML version deleted]]
On 12 January 2008 at 16:18, Sandrine-et-Francois wrote: | Dear R-list, | I'm experiencing some problems while using "strptime", which I don't understand. | | > str(natver) | 'data.frame': 154 obs. of 8 variables: | $ ID : Factor w/ 14 levels "AC","ALS","FA",..: 10 11 9 1 4 8 13 3 14 12 ... | $ CdBMin : int 22 22 26 26 28 23 27 23 25 26 ... | $ CdBMax : int 22 24 27 26 32 26 29 30 29 28 ... | $ Hrend : int 184 NA 120 168 NA 152 165 160 140 140 ... | $ Age : int 28 32 44 21 35 47 36 29 36 43 ... | $ Weight : int 63 70 80 57 69 74 82 71 85 70 ... | $ variable: Factor w/ 11 levels "X50","X100","X150",..: 1 1 1 1 1 1 1 1 1 1 ... | $ value : Factor w/ 47 levels "00:00:36","00:00:39",..: 1 2 4 3 3 4 5 7 8 6 ... | > | > head(natver) | ID CdBMin CdBMax Hrend Age Weight variable value | 1 PHu 22 22 184 28 63 X50 00:00:36 | 2 PK 22 24 NA 32 70 X50 00:00:39 | 3 PH 26 27 120 44 80 X50 00:00:46 | 4 AC 26 26 168 21 57 X50 00:00:42 | 5 FT 28 32 NA 35 69 X50 00:00:42 | 6 OA 23 26 152 47 74 X50 00:00:46 | > | > natver$Time<-strptime(natver$value, format="%d/%m/%Y %H:%M:%S") | | Erreur dans `$<-.data.frame`(`*tmp*`, "Time", value = list(sec = c(NA_real_, : | le tableau de remplacement a 9 lignes, le tableau remplac? en a 154 It's a FAQ. Try natver$Time <- as.POSIXct(strptime(natver$value, format="%d/%m/%Y %H:%M:%S")) to cast the nine-element list of POSIXlt results generated by strptime into a single figure POSIXct. Amicalement, Dirk -- Three out of two people have difficulties with fractions.