Dear all, I often use dates and times in analyses. I just can't figure out how to format my date or time column in R. So, apparently R sees the date as something other than date (character). Let's say I am opening a CSV file, one of the columns of which is a date or time. How do I specify that when opening the file? Thanks for the help, Jim -- ------------------------------------- James J. Roper, Ph.D. Universidade Federal do Paran? Depto. de Zoologia Caixa Postal 19020 81531-990 Curitiba, Paran?, Brasil ====================================E-mail: jjroper at gmail.com Phone/Fone/Tel?fono: 55 41 33611764 celular: 55 41 99870543 ====================================Zoologia na UFPR http://zoo.bio.ufpr.br/zoologia/ Ecologia e Conserva??o na UFPR http://www.bio.ufpr.br/ecologia/ ------------------------------------- http://jjroper.sites.uol.com.br Curr?culo Lattes http://lattes.cnpq.br/2553295738925812
there are probably many other ways but check out read.zoo. I cans end you of read.zoo also if you like. Let me know. -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of James J. Roper Sent: Wednesday, November 22, 2006 4:18 PM To: r-help at stat.math.ethz.ch Subject: [R] data in form of a date Dear all, I often use dates and times in analyses. I just can't figure out how to format my date or time column in R. So, apparently R sees the date as something other than date (character). Let's say I am opening a CSV file, one of the columns of which is a date or time. How do I specify that when opening the file? Thanks for the help, Jim -- ------------------------------------- James J. Roper, Ph.D. Universidade Federal do Paran? Depto. de Zoologia Caixa Postal 19020 81531-990 Curitiba, Paran?, Brasil ====================================E-mail: jjroper at gmail.com Phone/Fone/Tel?fono: 55 41 33611764 celular: 55 41 99870543 ====================================Zoologia na UFPR http://zoo.bio.ufpr.br/zoologia/ Ecologia e Conserva??o na UFPR http://www.bio.ufpr.br/ecologia/ ------------------------------------- http://jjroper.sites.uol.com.br Curr?culo Lattes http://lattes.cnpq.br/2553295738925812 ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -------------------------------------------------------- This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
Read the help desk article in R News 4/1. On 11/22/06, James J. Roper <jjroper at gmail.com> wrote:> Dear all, > > I often use dates and times in analyses. I just can't figure out how to > format my date or time column in R. So, apparently R sees the date as > something other than date (character). Let's say I am opening a CSV > file, one of the columns of which is a date or time. How do I specify > that when opening the file? > > Thanks for the help, > > Jim > > -- > ------------------------------------- > James J. Roper, Ph.D. > Universidade Federal do Paran? > Depto. de Zoologia > Caixa Postal 19020 > 81531-990 Curitiba, Paran?, Brasil > ====================================> E-mail: jjroper at gmail.com > Phone/Fone/Tel?fono: 55 41 33611764 > celular: 55 41 99870543 > ====================================> Zoologia na UFPR > http://zoo.bio.ufpr.br/zoologia/ > Ecologia e Conserva??o na UFPR > http://www.bio.ufpr.br/ecologia/ > ------------------------------------- > http://jjroper.sites.uol.com.br > Curr?culo Lattes > http://lattes.cnpq.br/2553295738925812 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
James J. Roper escribi?:> Dear all, > > I often use dates and times in analyses. I just can't figure out how to > format my date or time column in R. So, apparently R sees the date as > something other than date (character). Let's say I am opening a CSV > file, one of the columns of which is a date or time. How do I specify > that when opening the file? > > Thanks for the help, > > Jim > >Jim, Suppose a matrix F (6575,189) where rows are days and columns some grid points: First we set the starting date of the series (6575 is the total number of days): library(zoo) x.Date<-as.Date("1987-12-31")+ c(1:6575) F.zoo <- zoo(F, x.Date) #then take a look F.zoo[,1] HTH Antonio
Hi, 2006/11/22, James J. Roper <jjroper at gmail.com>:> I often use dates and times in analyses. I just can't figure out how to > format my date or time column in R. So, apparently R sees the date as > something other than date (character). Let's say I am opening a CSV > file, one of the columns of which is a date or time. How do I specify > that when opening the file?In the xlsReadWrite*Pro* version I have implemented an oleDateTime (and oleDate and oleTime) class which works quite nicely with Excel dates - info: http://treetron.googlepages.com/ - download zip: http://treetron.googlepages.com/xlsReadWritePro_1.0.5.zip If you are on windows you might want to try that out. The xlsReadWritePro version is not free like xlsReadWrite, sorry. But as you work in ecology I'll send you a free key (if non-free packages are in principle acceptable for you). Just contact me off list. In the next version of the free xlsReadWrite package I have at least implemented that dates will be retrieved as ISO formated date/time strings. The format is fixed and you are able to convert this to R date related classes (e.g. chron, date, POSIXt/ct/lt, fCalendar). - The new xlsReadWrite is finished but not yet uploaded, I just uploaded it "unofficially": - bin zip: http://treetron.googlepages.com/xlsReadWrite_1.2.0.zip - source: http://treetron.googlepages.com/xlsReadWrite_1.2.0.tar.gz It should be ok, i.e. runs my internal tests, but I want to add some more tests before official release. New is also that you can specify rowNames for matrices (and not only data.frame). Regards, Hans-Peter