[R] lattice and dates (correcting e-mail formatting glitch - sorry!!)

Nick Sherrard reduplicativeblending at yahoo.co.uk
Thu Jun 27 17:30:24 CEST 2002



Hi

I'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, PhD
reduplicativeblending at yahoo.co.uk
______________________________________________________
Subject: [R] lattice and dates I've got some data that
is recorded at various times during the day. I create
a time stamp is created from date and time strings
like this: > timestamp <- strptime( paste( datestring,
timestring), "%D %X" ) Then I'd like to use lattice to
plot the time dependence by doing something like >
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 I can'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 - 



__________________________________________________

Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list