简体   繁体   中英

Reading from CSV file in R and formatting dates and times with strptime()

I want to format my timestamp data with strptime()

Reading from a txt file as a CSV ( read.csv(time.txt) ). My time.txt only contains one column with dates, time. For example,

29/1/12 19:48
30/12/13 21:48 
31/4/13 2:49

FYI, been instructed use only strptime() function. I am getting the result something like this:

V1
NA

mydata <- read.csv("time.txt", header = FALSE)
x <- mydata
strptime(x,format = "%d/%m/%y %H:%M")

Answered in comments:

strptime(x$V1,format = "%d/%m/%y %H:%M")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM