lundi 1 septembre 2014

Extracting parts of a factor


Vote count:

0




I am trying to extract parts of a factor within a data.frame that look like the following:


aug$V5 <- c("00:00:00","01:01:05","04:32:22")


The format is in a factor and I want to extract the first two digits, as they are the hours that I am interested in, and place them in a different column within my vector.


Output looks like this:


aug$hours <- c("00","01","04")


I think I just need to use the sub function but am unsure.


Thanks.



asked 1 min ago







Extracting parts of a factor

Aucun commentaire:

Enregistrer un commentaire