R-help, I'm using 'xyplot' in lattice package which plots length frecuencies by year (10). The order I get is not logical and the 'index.cond' argument to 'xyplot' is a bit cumbersome when it comes to plot a great deal of (in my case years). I have tried sorting the conditioning variable but still get the same result. Is there any easy way to do it without making use of 'index.cond' ? The function call is as follows: xyplot ( number ~ cm | as.factor(test$year) , data=test) Thanks in advance> version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 0.1 year 2004 month 11 day 15 language R
Luis Ridao Cruz wrote:> R-help, > > I'm using 'xyplot' in lattice package which plots length frecuencies by > year (10). > The order I get is not logical and the 'index.cond' argument to > 'xyplot' is a bit cumbersome when it comes to plot a great deal of (in > my case years). > > I have tried sorting the conditioning variable but still get the same > result. > > Is there any easy way to do it without making use of 'index.cond' ? > > The function call is as follows: > > xyplot ( number ~ cm | as.factor(test$year) , data=test)Not reproducible for us, we don't have "test", so please make your example small and reproducible. Uwe Ligges> > Thanks in advance > > > >>version > > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 0.1 > year 2004 > month 11 > day 15 > language R > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Here is a 'subset' of the ' test ' data . xyplot ( number ~ cm | as.factor(test$year) , data=test)> testyear cm number 34 1995 72 34 35 1995 73 37 36 1995 74 31 37 1995 75 13 38 1995 76 18 39 1995 77 4 40 1995 78 10 41 1995 79 6 42 1995 80 4 43 1995 81 2 44 1995 83 2 45 1995 84 5 46 1995 87 1 47 1996 32 2 48 1996 34 6 49 1996 36 1 50 1996 37 31 51 1996 38 11 52 1996 39 58 53 1996 40 134 54 1996 41 164 55 1996 42 391 94 1997 40 2 95 1997 41 1 96 1997 42 5 97 1997 43 37 142 1998 38 6 143 1998 39 8 144 1998 40 10 145 1998 41 22 146 1998 42 43 191 1999 35 2 192 1999 36 10 193 1999 37 4 194 1999 38 12 195 1999 39 34 196 1999 40 60 239 2000 38 1 240 2000 39 5 241 2000 40 2 242 2000 41 7 243 2000 42 21 284 2001 38 1 285 2001 39 5 286 2001 40 6 287 2001 41 14 288 2001 42 56 289 2001 43 68 332 2002 32 1 333 2002 36 12 334 2002 37 3 335 2002 38 4 336 2002 39 13 386 2003 34 3 387 2003 37 3 388 2003 38 2 389 2003 39 4 390 2003 40 26 391 2003 41 25 392 2003 42 41 393 2003 43 59 438 2004 35 4 439 2004 36 3 440 2004 37 4 441 2004 38 18 442 2004 39 24 443 2004 40 50>>> Uwe Ligges <ligges at statistik.uni-dortmund.de> 01/03/2005 15:40:15 >>>Luis Ridao Cruz wrote:> R-help, > > I'm using 'xyplot' in lattice package which plots length frecuenciesby> year (10). > The order I get is not logical and the 'index.cond' argument to > 'xyplot' is a bit cumbersome when it comes to plot a great deal of(in> my case years). > > I have tried sorting the conditioning variable but still get thesame> result. > > Is there any easy way to do it without making use of 'index.cond' ? > > The function call is as follows: > > xyplot ( number ~ cm | as.factor(test$year) , data=test)Not reproducible for us, we don't have "test", so please make your example small and reproducible. Uwe Ligges> > Thanks in advance > > > >>version > > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 0.1 > year 2004 > month 11 > day 15 > language R > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide!http://www.R-project.org/posting-guide.html
Luis Ridao Cruz allegedly said on 3/1/2005 8:50 AM:> R-help, > > I'm using 'xyplot' in lattice package which plots length frecuencies by > year (10). > The order I get is not logical and the 'index.cond' argument to > 'xyplot' is a bit cumbersome when it comes to plot a great deal of (in > my case years). > > I have tried sorting the conditioning variable but still get the same > result. > > Is there any easy way to do it without making use of 'index.cond' ? > > The function call is as follows: > > xyplot ( number ~ cm | as.factor(test$year) , data=test) > > > Thanks in advance > > > >>version > > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 0.1 > year 2004 > month 11 > day 15 > language R >Luis, You should set test$year as ?ordered: # set `levels' to the order you want the panels to appear test$year <- ordered(test$year, levels = .......) xyplot ( number ~ cm | year , data = test) --sundar
On Tuesday 01 March 2005 08:50, Luis Ridao Cruz wrote:> R-help, > > I'm using 'xyplot' in lattice package which plots length frecuencies > by year (10). > The order I get is not logical and the 'index.cond' argument to > 'xyplot' is a bit cumbersome when it comes to plot a great deal of > (in my case years). > > I have tried sorting the conditioning variable but still get the same > result. > > Is there any easy way to do it without making use of 'index.cond' ? > > The function call is as follows: > > xyplot ( number ~ cm | as.factor(test$year) , data=test)The order of panels would be the same as you would get by> levels(as.factor(test$year))So what you really need to figure out is how to explicitly specify the order of levels when creating a factor. In other words, this is not a lattice issue. How best to do this depends on details you haven't given, specifically, what you think the 'logical' order is. Reading ?factor and ?reorder.factor might help. -Deepayan
Luis Ridao Cruz wrote:> Here is a 'subset' of the ' test ' data . > > xyplot ( number ~ cm | as.factor(test$year) , data=test) > > >>test > > year cm number > 34 1995 72 34 > 35 1995 73 37 >[SNIP, was NTW a) not easily reproducible and b) too much waste of bandwith] I still don't see any problem? The order seems to be fine, and setting "index.cond" works as expected ... Uwe Ligges> > >>>>Uwe Ligges <ligges at statistik.uni-dortmund.de> 01/03/2005 15:40:15 >>>> > > Luis Ridao Cruz wrote: > > >>R-help, >> >>I'm using 'xyplot' in lattice package which plots length frecuencies > > by > >>year (10). >>The order I get is not logical and the 'index.cond' argument to >>'xyplot' is a bit cumbersome when it comes to plot a great deal of > > (in > >>my case years). >> >>I have tried sorting the conditioning variable but still get the > > same > >>result. >> >>Is there any easy way to do it without making use of 'index.cond' ? >> >>The function call is as follows: >> >>xyplot ( number ~ cm | as.factor(test$year) , data=test) > > > Not reproducible for us, we don't have "test", so please make your > example small and reproducible. > > Uwe Ligges > > >>Thanks in advance >> >> >> >> >>>version >> >> _ >>platform i386-pc-mingw32 >>arch i386 >>os mingw32 >>system i386, mingw32 >>status >>major 2 >>minor 0.1 >>year 2004 >>month 11 >>day 15 >>language R >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide! > > http://www.R-project.org/posting-guide.html
I do the following: test$year <- factor (test$year , ordered = TRUE) xyplot ( number~cm | year, data = test , type = "l" ) and still get the same. Luis>>> Sundar Dorai-Raj <sundar.dorai-raj at pdf.com> 01/03/2005 16:04:34 >>>Luis Ridao Cruz allegedly said on 3/1/2005 8:50 AM:> R-help, > > I'm using 'xyplot' in lattice package which plots length frecuenciesby> year (10). > The order I get is not logical and the 'index.cond' argument to > 'xyplot' is a bit cumbersome when it comes to plot a great deal of(in> my case years). > > I have tried sorting the conditioning variable but still get thesame> result. > > Is there any easy way to do it without making use of 'index.cond' ? > > The function call is as follows: > > xyplot ( number ~ cm | as.factor(test$year) , data=test) > > > Thanks in advance > > > >>version > > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 0.1 > year 2004 > month 11 > day 15 > language R >Luis, You should set test$year as ?ordered: # set `levels' to the order you want the panels to appear test$year <- ordered(test$year, levels = .......) xyplot ( number ~ cm | year , data = test) --sundar