[R] lattice and dates
Nick Sherrard
reduplicativeblending at yahoo.co.uk
Thu Jun 27 13:37:11 CEST 2002
HiI'm fairly new to R and the list, so please take what I say accordingly!Far as I can see, strptime gives you a string in some specified format. In order to do any kind of numerically-based modelling with that, you need to obtain a number to work with.One way to do this is by getting the time with Sys.time() instead and coercing it to a number using as.integer():> as.integer(Sys.time())I dare say you could also set up a structure in which there are both numeric and string fields, do your modelling with the former and labelling with the latter:> now=Sys.time()> numero= as.integer(now)> dateo= format(now, "%a, %b %d, %Y")> timeo= format (now, "%X")> item=list(numeric=numero, strings=c(timeo,dateo))This seems to do the trick, and gives you a list with values that look like this.> item$numeric[1] 1025176725$strings[1] "12:18:45" "Thu, Jun 27, 2002"I guess many of us might also choose to normalize the $numeric by subtracting some suitable base date/time from each reading of numero, which appears to be the number of seconds since 1/1/70, to give a more useful time origin!Nick Sherrard, PhDreduplicativeblending at yahoo.co.uk______________________________________________________Subject: [R] lattice and datesI've got some data that is recorded at various times during theday. I create a time stamp is created from date and timestrings like this: > timestamp xyplot( value ~ timestamp | subject )This fails with Error in as.double.default(x) : (list) object cannot be coerced to vector type 14 In addition: Warning message: Both x and y should be numeric in: xyplot( value ~ timestamp | subject )I was sure I saw something like this on r-help recently, but Ican't seem to track it down now. Can anyone help me out?Thanks, Mike- -- Michael A. Miller mmiller3 at iupui.edu Imaging Sciences, Department of Radiology, IU School of Medicine-
---------------------------------
Relive the FIFA World Cup goals with exclusive video highlights!
http://fifaworldcup.yahoo.com/fc/en
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20020627/5616354f/attachment.html
More information about the R-help
mailing list