[R] aggregate with non-scalar functions

2010-08-04 Thread David Carslaw
Hi R-users, Since R.2.11 aggregate can now deal with non-scalar functions, which is very useful to me. However, I have a question about how best to process the output. test - data.frame(a = rep(c(g1, g2), each = 50), b = runif(100)) res - aggregate(test$b, list(group = test$a), function(x)

[R] xyplot axis scaling with dates/times

2009-07-23 Thread David Carslaw
Dear R users, I'm trying to get a good x-scale and labels on a plot like the one below. library(lattice) ## make almost a year of hourly data: mydat - data.frame(dates = Sys.time() + 3600 * (1:7000), y = runif(7000)) ## plot it xyplot(y ~ dates, data = mydat, type = l) Only one x-label is

Re: [R] Creating smooth color regions with panel.contourplot()

2008-09-17 Thread David Carslaw
I think this is a very useful function that I imagine has wide appeal - thanks. Using the code below produces the plot OK but when I try and copy/save it (as a metafile) I receive the following error and an hourglass: Error: invalid graphics state [using XP, 2.72, lattice 0.17.13] Regards,

[R] how to split a data framed with sequences

2008-09-09 Thread David Carslaw
Hi all, Given a data frame: my.df - data.frame(a = c(1:5, 1:10, 1:20), b = runif(35)) I want to split it by a such that I end up with a list containing 3 components i.e. the first containing a = 1 to 5, the second a = 1 to 10 etc. In other words, sets of sequences of a. I can't seem to find

[R] text processing for plots

2008-09-05 Thread David Carslaw
posts etc., and would appreciate your help! Many thanks. David Carslaw - Institute for Transport Studies University of Leeds -- View this message in context: http://www.nabble.com/text-processing-for-plots-tp19331219p19331219.html Sent from the R help mailing list archive at Nabble.com

[R] subset grouped data with quantile and NA's

2008-08-22 Thread David Carslaw
with the other columns fac and other. Note that quantile will return different length vectors due to different numbers of NAs for a and b. There's something I'm just not seeing - can you help? Many thanks. David Carslaw - Institute for Transport Studies University of Leeds -- View this message

Re: [R] Frequency vector

2008-08-12 Thread David Carslaw
how about: a - c(1,1,1,1,2,3,4,5,5) b - as.data.frame(table(a)) b a Freq 1 14 2 21 3 31 4 41 5 52 which you can then select the bits you want from. David dennis11 wrote: I want to create a vecor with frequencies. I have tried this: a - c(1,1,1,1,2,3,4,5,5)