Reputation: 83
Whenever I read in my table (its a .txt) and set the date column to actual dates, it just returns that column as all NAs. Here's what I'm running.
columnH <- read.table("file.txt", header=FALSE, sep="")
This works fine. Reads in the .txt file with ease and no formatting issues. The data I'm setting as date is :
("01-29-10",
"01-29-93", "01-29-99", "01-30-04", "01-30-09", "01-30-15", "01-30-98",
"01-31-00", "01-31-01", )
I chopped that down heavily.
Anyway, here's where it messes up.
columnH$V1 <- as.Date(columnH$V1, format="%m/%d/%Y")
This returns all those dates as NA
. I've tried with different formats and no format (basically letting R do it itself) but I haven't had any luck.
Any help is appreciated.
Thanks
Upvotes: 1
Views: 2817
Reputation: 2000
Doesn't it work with this formatting?
columnH$V1 <- as.Date(columnH$V1, format="%m-%d-%y")
Check if the dash is a special character instead of "-". In that case, you just need to change the encoding.
Upvotes: 2