Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to delete ":00" from 12:00:00 AM : 11:00:00 PM for each value in a column R

I am attempting to change this value

hourlyIntensities_mergedcleannew
[1] "12:00:00 AM" "1:00:00 AM" "2:00:00 AM" "3:00:00 AM" "4:00:00 AM" "5:00:00 AM" "6:00:00 AM"
[8] "7:00:00 AM" "8:00:00 AM" "9:00:00 AM" "10:00:00 AM" "11:00:00 AM" "12:00:00 PM" "1:00:00 PM"
[15] "2:00:00 PM" "3:00:00 PM" "4:00:00 PM" "5:00:00 PM" "6:00:00 PM" "7:00:00 PM" "8:00:00 PM"
[22] "9:00:00 PM" "10:00:00 PM" "11:00:00 PM"

to this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[1] "12:00 AM" "1:00AM" "2:00AM" "3:00 AM" .. etc

thank you

>Solution :

Using gsub,

x <- c("12:00:00 AM", "1:00:00 AM", "2:00:00 AM", "3:00:00 AM", "4:00:00 AM", "5:00:00 AM", "6:00:00 AM")
gsub(':00 '," ",x)

The output would be

[1] "12:00 AM" "1:00 AM"  "2:00 AM"  "3:00 AM"  "4:00 AM"  "5:00 AM" 
[7] "6:00 AM"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading