R date m/d/y to yyyy-mm-dd -


i trying change date within dataframe correct format within r. (m/d/y correct yyyy-mm-dd).

i have data looks this

    date      time  ph 1   1/4/1981  9:00  3.9  2   1/8/1981  8:30  3.9 

etc

the name of data frame working in data.cat.ac

i tried

data.cat.ac[,1]$date <- as.date(data.cat.ac[,1]$date, "%y/%m/%d")  

...but did not work.

i getting error,

$ operator invalid atomic vectors 

any tips or pointers on doing wrong?

when use as.date, should not enter format want output. instead enter format in data.

as.date("1/4/1981", format="%m/%d/%y") [1] "1981-01-04" 

we got lucky in case in desired output happens default output. learning purposes, let's wanted format "dd:mm:yyyy". after converting date format did above, use:

format(x2, "%m:%d:%y") [1] "01:04:1981" 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -