[R] Adjusting axis labels on lattice xyplot
Rich Shepard
rshepard at appl-ecosys.com
Sat Oct 15 00:51:39 CEST 2016
On Fri, 14 Oct 2016, David Winsemius wrote:
>> rain <- source("~/raindata.dat")
>> str(rain)
> List of 2
> $ value :'data.frame': 341 obs. of 3 variables:
> ..$ station: Factor w/ 6 levels "0.3E","0.6W",..: 1 1 1 1 1 1 1 1 1 1 ...
> ..$ date : Factor w/ 62 levels "2013-12-01","2013-12-02",..: 32 33 34 35 36 37 38 39 40 41 ...
> ..$ amount : Factor w/ 48 levels "","0.00","0.01",..: 1 1 3 2 2 2 12 18 34 14 ...
> $ visible: logi TRUE
David,
I left the station as a factor and changed the date using
as.Date(as.character...) and the amount using as.numeric.
> When you do that you can see the only the first item in the length2 list
> is likely to be useful:
I'm not seeing to what the 'List of 2' refers in the data.frame.
This is the script I sourced:
rain <- read.csv("daily_records.csv", header=T, sep=",")
require(lattice)
rain$date <- as.Date(as.character(rain$date))
rain$amount <- as.numeric(rain$amount)
xyplot(rain$amount ~ rain$date | rain$station, main="Weather Stations", xlab="Date", ylab="Amount (inches)", pch=20, col=132)
What did I do incorrectly here?
> And the date column is a factor. Fortunately the as.Date.factor function
> doesn't need as.chaacter anymore:
Oh. Thanks.
> The place on the ?xyplot help page to look is in the section on `scales`.
> There's no difficulty using 'rot' as long as it is in the correct place
> which in this instance is `x` sublist of the `scales` list
> xyplot(amount ~ date | station, data=rain, main="Weather Stations",
> xlab="Date", ylab="Amount (inches)", pch=16, col=132,
> scales=list(y=list(at=0:4),
> x=list(at=seq(min(rain$date), max(rain$date), by='week'), rot=90) )
> )
That's what I missed: where the scales command is placed, and
understanding how to use all the components.
I need to figure out why I'm no longer seeing the help files. As far as I
know they should be loaded when I invoke R.
Thanks very much,
Rich
More information about the R-help
mailing list