Re: [R] trouble with small multiples on a date variable

2012-04-01 Thread Duncan Mackay

Hi David

Are you having problems getting the data in or further down the track

If it is dBase III or IV (opens in excel with the appropriate excel 
extension filter) you can use


library(foreign)
data - read.dbf(d:/Cic/dbf/dsw3.dbf)
 str(data)
'data.frame':   43730 obs. of  8 variables:
 $ DATE  : Date, format: 1889-01-01 1889-01-02 1889-01-03 
1889-01-04 ...

 $ DSW1  : num  2.38 2.21 2.66 2.12 2.11 2.1 2.09 2.08 2.08 2.07 ...
 $ DSW2  : num  24.3 22.3 22 21.1 20.4 ...
 $ DSW3  : num  36.6 34.6 33.7 31 27.7 ...
 $ DSW4  : num  57.9 57.5 57.5 57.3 57.2 ...
 $ DSW5  : num  58 58 58 58 58 ...
 $ DSW   : num  63.2 59.1 58.3 54.2 50.2 ...
 $ JULIAN: int  1 2 3 4 5 6 7 8 9 10 ...
 - attr(*, data_types)= chr  D N N N ...

Convert to date format by converting the posix to date ? as.Date (I 
have forgotton-- do not use posix often)


Then

xyplot(DSW1 ~ DATE, data, type = l,aspect=0.25)

aspect added due to 43K+ records
or by years - short version

xyplot(DSW1 ~ JULIAN|format(DATE,%Y), data, type = l)

This is one with a combined character of date and time

ln1 = read.dbf(d:/tmp/ln1.dbf,as.is=T)
 str(ln1)
'data.frame':   2216 obs. of  7 variables:
 $ DATE : Date, format: 2004-04-15 2004-04-15 2004-04-15 
2004-04-15 ...

 $ TIME : chr  19:40:00 19:45:00 19:50:00 19:55:00 ...
 $ TD_01: num  15.5 15.3 15.1 15.1 15.1 14.9 14.9 14.6 14.6 14.4 ...
 $ TD_03: num  21.9 21.9 21.7 21.7 21.7 21.5 21.5 21.5 21.5 21.2 ...
 $ SR_04: num  0 0 0 0 0 0 0 0 0 0 ...
 $ RG_05: num  0 0 0 0 0 0 0 0 0 0 ...
 $ WR_06: num  0.4 0.3 0.4 0.3 0.4 0.3 0.3 0.3 0.4 0.3 ...
 - attr(*, data_types)= chr  D C N N ...
 ldt - paste(ln1[,1],ln1[,2])
 head(ldt)
[1] 2004-04-15 19:40:00 2004-04-15 19:45:00 2004-04-15 19:50:00 
2004-04-15 19:55:00 2004-04-15 20:00:00 2004-04-15 20:05:00

 ld.date = as.Date(ldt, %Y-%m-%d %H:%M:%S)
 head(ld.date)
[1] 2004-04-15 2004-04-15 2004-04-15 2004-04-15 2004-04-15 
2004-04-15


 str(ld.date)
 Date[1:2216], format: 2004-04-15 2004-04-15 2004-04-15 
2004-04-15 2004-04-15


As usual the more info provided the more appropriate the response

Version 2.14.1

HTH

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email home: mac...@northnet.com.au


At 12:27 1/04/2012, you wrote:

Hello,

I am loading a DBF file into R via JGR and am having trouble creating small
multiple histograms on a date variable. Hist() handles the variable
correctly. But I've been unable to work with lattice or ggplot2 despite
trying format() and as.POSIXct(). Dates are in the format 2010-05-15 and
the grouping variable is categorical. I'd appreciate it if someone would
provide an example.

Thank you,
-david

__
R-help@r-project.org 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.


__
R-help@r-project.org 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.


[R] trouble with small multiples on a date variable

2012-03-31 Thread davideps
Hello,

I am loading a DBF file into R via JGR and am having trouble creating small
multiple histograms on a date variable. Hist() handles the variable
correctly. But I've been unable to work with lattice or ggplot2 despite
trying format() and as.POSIXct(). Dates are in the format 2010-05-15 and
the grouping variable is categorical. I'd appreciate it if someone would
provide an example.

Thank you,
-david

__
R-help@r-project.org 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.