Re: [R] bwplot in ascending order

2011-05-02 Thread Uwe Ligges



On 01.05.2011 22:52, Doran, Harold wrote:

Can anyone point me to examples with R code where bwplot in lattice is used to 
order the boxes in ascending order? I have found the following discussion and 
it partly works. But, I have a conditioning variable, so my example is more like

bwplot(var1 ~ var2|condition, dat)



I guess you are looking for something along

bwplot(var1 ~ var2 | reorder(condition, var2, median), dat)

Uwe Ligges




Th example in the discussion below works only when there is not a conditioning 
variable as far as I can tell. I can tweak the example below to work, but then 
I get some ugly labels in the lattice plot. It seems index.cond is supposed to 
help me solve this, but I cannot find good examples showing its use.

Thanks
Harold

http://r.789695.n4.nabble.com/bwplot-reorder-factor-on-y-axis-td790903.html
__
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.


Re: [R] bwplot in ascending order

2011-05-02 Thread Mark Difford
On May 01 (2011) Harold Doran wrote:

 Can anyone point me to examples with R code where bwplot in lattice is
 used to order the boxes in 
 ascending order?

You don't give an example and what you want is not entirely clear.

Presumably you want ordering by the median (boxplot, and based on the
example you point to, where the median is mentioned as an _example_).

Is this what you want?

##
bwplot(var1 ~ var2|condition, dat, index.cond = function(x, y) reorder(y, x,
median))  ## if x is numeric
bwplot(var1 ~ var2|condition, dat, index.cond = function(x, y) reorder(x, y,
median))  ## if y is numeric

Regards, Mark.

--
View this message in context: 
http://r.789695.n4.nabble.com/bwplot-in-ascending-order-tp3488557p3489544.html
Sent from the R help mailing list archive at Nabble.com.

__
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.


Re: [R] bwplot in ascending order

2011-05-02 Thread Doran, Harold
Doesn't seem to work. My data structure is below (I will send data to anyone 
off-list who could offer support).

The following code below does work, but since I concatenate Region and Gender, 
the labels on the lattice are ugly.

dat$test - factor(paste(dat$Region, dat$Gender, sep='_'))
bymedian - with(dat, reorder(test, finalRank, median))
bwplot(reorder(test, finalRank, median) ~ finalRank|Gender, dat, 
subset = Region !=,
scale='free',
xlab = 'Total Score',
ylab = 'Region',
)

 str(dat)
'data.frame':   58921 obs. of  16 variables:
 $ Athlete   : int  13 13 13 13 13 14 14 15 15 15 ...
 $ Workout   : Factor w/ 6 levels 11.1,11.2,..: 1 2 3 4 5 1 2 1 1 2 ...
 $ Result: int  309 375 46 100 300 158 232 353 359 479 ...
 $ Valid : Factor w/ 6 levels bogus,invalid,..: 5 5 5 5 5 5 5 5 5 5 ...
 $ Gender: Factor w/ 2 levels female,male: 2 2 2 2 2 2 2 2 2 2 ...
 $ Height.cm.: num  196 196 196 196 196 ...
 $ Weight.kg.: num  97.7 97.7 97.7 97.7 97.7 ...
 $ Age   : int  29 29 29 29 29 42 42 24 24 24 ...
 $ Region: Factor w/ 18 levels ,Africa,Asia,..: 16 16 16 16 16 13 13 
18 18 18 ...
 $ AgeCut: num  2 2 2 2 2 4 4 2 2 2 ...
 $ Height.met: num  1.96 1.96 1.96 1.96 1.96 ...
 $ spVar : chr  11.1_male 11.2_male 11.3_male 11.4_male ...
 $ Rank  : int  1567 2253 2050 1651 1462 8155 7624 322 208 206 ...
 $ totalRank : int [1:58921(1d)] 8983 8983 8983 8983 8983 15779 15779 1252 1252 
1252 ...
  ..- attr(*, dimnames)=List of 1
  .. ..$ : chr  13 13 13 13 ...
 $ finalRank : int  1274 1274 1274 1274 1274 2643 2643 81 81 81 ...
 $ totalScore: int [1:58921(1d)] 1130 1130 1130 1130 1130 390 390 1768 1768 
1768 ...
  ..- attr(*, dimnames)=List of 1
  .. ..$ : chr  13 13 13 13 ...

 -Original Message-
 From: Uwe Ligges [mailto:lig...@statistik.tu-dortmund.de]
 Sent: Monday, May 02, 2011 4:58 AM
 To: Doran, Harold
 Cc: r-help@r-project.org
 Subject: Re: [R] bwplot in ascending order
 
 
 
 On 01.05.2011 22:52, Doran, Harold wrote:
  Can anyone point me to examples with R code where bwplot in lattice is used
 to order the boxes in ascending order? I have found the following discussion
 and it partly works. But, I have a conditioning variable, so my example is
 more like
 
  bwplot(var1 ~ var2|condition, dat)
 
 
 I guess you are looking for something along
 
 bwplot(var1 ~ var2 | reorder(condition, var2, median), dat)
 
 Uwe Ligges
 
 
 
  Th example in the discussion below works only when there is not a
 conditioning variable as far as I can tell. I can tweak the example below to
 work, but then I get some ugly labels in the lattice plot. It seems index.cond
 is supposed to help me solve this, but I cannot find good examples showing its
 use.
 
  Thanks
  Harold
 
  http://r.789695.n4.nabble.com/bwplot-reorder-factor-on-y-axis-td790903.html
  __
  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] bwplot in ascending order

2011-05-01 Thread Doran, Harold
Can anyone point me to examples with R code where bwplot in lattice is used to 
order the boxes in ascending order? I have found the following discussion and 
it partly works. But, I have a conditioning variable, so my example is more like

bwplot(var1 ~ var2|condition, dat)

Th example in the discussion below works only when there is not a conditioning 
variable as far as I can tell. I can tweak the example below to work, but then 
I get some ugly labels in the lattice plot. It seems index.cond is supposed to 
help me solve this, but I cannot find good examples showing its use.

Thanks 
Harold

http://r.789695.n4.nabble.com/bwplot-reorder-factor-on-y-axis-td790903.html
__
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.