I have a data.frame like this:
> aaa
AdjClose
2012-01-03 15.5
2012-01-04 18.8
2012-01-05 13.9
Doing dt$AdjClose I get get the “column” with the prices, but, how to get the dates ?
Thank you!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
rownames(aaa)will give them to you. Do note that they will be a character vector, not something R considers dates. For that you need to convert the characters to dates usingas.Date(). This is illustrated below:I didn’t need to specify a
formatfor theas.Date()call as your characters are already in the default format.