I have read a csv file in R. After reading I need to transform the Data column as Date object and Time as Time Object. How do I do it. The file is in memory at this point in time. Also How do I get classes of all columns in a file? I tried lapply and sapply. It prints out name of column to console but not say anything abut class.
Asked
Active
Viewed 52 times
0
-
2Try to ask one question at a time. Show some representative data with a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Show the code you've tried and describe exactly how it doesn't work. – MrFlick Dec 04 '14 at 18:52
1 Answers
1
You're going to need the strptime function. The exact code is going to differ depending on the time format of the .csv file, however you can find the way to do it at the link below here.
So if your date-time is given like this: 2014/01/04 12:30:36
Then your code will look something like this:
strptime(data$column_name, format="%Y/%m/%d %H:%M:%S")
For finding the class, simply use the class() function.
These tools can be discovered fairly easily with a little bit of research. Next time put in a little bit more effort before asking your question.
Hope this helps.

Dan Johnson
- 77
- 1
- 7