Re: [R] read.table behavior for Dates.

2010-04-17 Thread David Winsemius
On Apr 16, 2010, at 4:42 PM, Jeroen Ooms wrote: Ah Phil Spector is right, nothing is converted. I'm almost too embarrassed to admit it, but actually, it was Excel that tricked me. It displays date fields differently than they are stored in the csv file, and once you press 'save', it save

Re: [R] read.table behavior for Dates.

2010-04-16 Thread David Scott
Jeroen Ooms wrote: Ah Phil Spector is right, nothing is converted. I'm almost too embarrassed to admit it, but actually, it was Excel that tricked me. It displays date fields differently than they are stored in the csv file, and once you press 'save', it saves everything to a different format, co

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Jeroen Ooms
Ah Phil Spector is right, nothing is converted. I'm almost too embarrassed to admit it, but actually, it was Excel that tricked me. It displays date fields differently than they are stored in the csv file, and once you press 'save', it saves everything to a different format, completely unasked. N

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Phil Spector
Jeroen - read.table is not converting anything. You're confusing the output you see at yahoo with the contents of the csv file. two = readLines("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=07&b=19&c=2004&d=03&e=16&f=2010&g=d&ignore=.csv";) two[1:3] [1] "Date,Open,High,Low,Close,Volu

Re: [R] read.table behavior for Dates.

2010-04-16 Thread David Winsemius
On Apr 16, 2010, at 3:57 PM, Jeroen Ooms wrote: Yes I know I can manually do it, but I am using it for scripts in which users upload files. Hence, I don't know what's going to come; I don't know on before hand whether data will contain Dates, and in which columns they appear. This is why

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Greg Snow
e- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Jeroen Ooms > Sent: Friday, April 16, 2010 1:57 PM > To: r-help@r-project.org > Subject: Re: [R] read.table behavior for Dates. > > > Yes I know I can manually do it, but I am

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Henrique Dallazuanna
Try this: patt <- "\\d{4}[-/]\\d{2}[-/]\\d{2}" # could be \\d{2}[-/]\\d{2}[-/]\\d{4}, etc... idx <- colSums(sapply(myData, regexpr, pattern = patt)) > 0 myData[idx] <- lapply(myData[idx], as.Date) On Fri, Apr 16, 2010 at 4:57 PM, Jeroen Ooms wrote: > > Yes I know I can manually do it, but I am

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Jeroen Ooms
Yes I know I can manually do it, but I am using it for scripts in which users upload files. Hence, I don't know what's going to come; I don't know on before hand whether data will contain Dates, and in which columns they appear. This is why I was surprised that read.table has some (undocumented) b

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Henrique Dallazuanna
Try this: myData <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=07&b=19&c=2004&d=03&e=16&f=2010&g=d&ignore=.csv";, colClasses = c('Date', rep('numeric', 6))) On Fri, Apr 16, 2010 at 4:32 PM, Jeroen Ooms wrote: > > When read.table imports a table that includes a header c

Re: [R] read.table behavior for Dates.

2010-04-16 Thread Kjetil Halvorsen
use the argument colClasses of read.table Kjetil On Fri, Apr 16, 2010 at 3:32 PM, Jeroen Ooms wrote: > > When read.table imports a table that includes a header called 'Date', it > tries to recognize the date format. For example, if one imports this data > from Yahoo finance, the Date column is

[R] read.table behavior for Dates.

2010-04-16 Thread Jeroen Ooms
When read.table imports a table that includes a header called 'Date', it tries to recognize the date format. For example, if one imports this data from Yahoo finance, the Date column is automatically transformed to Y-m-d, whereis in the data it appears as m/d/Y: myData <- read.csv("http://ichart.