[R] Adjusting axis labels on lattice xyplot
dwinsemius at comcast.net
Sat Oct 15 01:46:05 CEST 2016
> On Oct 14, 2016, at 3:51 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> On Fri, 14 Oct 2016, David Winsemius wrote:
>>> rain <- source("~/raindata.dat")
>> 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
> 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=",")
> 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?
Well, you didn't send a text file with the contents of "daily_records.csv"; rather you sent a text file that was R code that would return a data object. I assigned it to the name `rain` before I realized it was a two item list. I then fixed the problems that assignment and the factor Dates presented so that I could then give a `data=rain` parameter to the xyplot function.
>> 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,
>> x=list(at=seq(min(rain$date), max(rain$date), by='week'), rot=90) )
Notice that the formula has just the column names rather than using `$`. But need to give `rain$date` to functions in hte scales list. It always seemed to me that the evaluation of names inside the scales list should also be evaluated inside the `data` environment but Deepayan didn't design it that way, so you need to "reach out" to get them pulled back in.
> 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.
So typing ?xyplot at the console doesn't bring up a help page? That would imply that you need to reinstall R.
> Thanks very much,
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Alameda, CA, USA
More information about the R-help