[R] bargraph.CI

yuanzhi yuanzhi.li at usherbrooke.ca
Thu Dec 12 05:15:09 CET 2013


 
William Dunlap wrote
> Furthermore, if you have a factor z with the levels in an undesirable
> order
> or missing some levels you can call
>   z <- factor(z, levels=betterOrderedLevels)
> to get them in the order you want.  E.g.,
> 
>   > z <- factor(c("High", "Low", "High"))
>   > table(z) # levels are in alphabetical order
>   z
>   High  Low 
>      2    1 
>   > # put them in semantically increasing order and add Medium
>   > z <- factor(z, levels=c("Low", "Medium", "High"))
>   > table(z)
>   z
>      Low Medium   High 
>        1      0      2 
> You can also rename them by adding the labels argument:
>   > z2 <- factor(z, levels=c("Low", "Medium", "High"),
> labels=c("L","M","H"))
>   > table(z2)
>   z2
>   L M H 
>   1 0 2
> 
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
> 
> 
>> -----Original Message-----
>> From: 

> r-help-bounces@

>  [mailto:

> r-help-bounces@

> ] On Behalf
>> Of Sarah Goslee
>> Sent: Wednesday, December 11, 2013 2:24 PM
>> To: Yuanzhi Li
>> Cc: r-help
>> Subject: Re: [R] bargraph.CI
>> 
>> Without knowing where you got bargraph.CI() I can't answer that part,
>> since it isn't part of base R, but the most likely cause is that you
>> did not specify the desired levels of your factor.
>> You can check with str().
>> 
>> Compare:
>> 
>> > testdata <- factor(c("a", "b", "a", "c", "b"))
>> > str(testdata)
>>  Factor w/ 3 levels "a","b","c": 1 2 1 3 2
>> >
>> > testdata <- factor(c("a", "b", "a", "c", "b"), levels=c("c", "b", "a"))
>> > str(testdata)
>>  Factor w/ 3 levels "c","b","a": 3 2 3 1 2
>> 
>> Sarah
>> 
>> On Wed, Dec 11, 2013 at 5:06 PM, Yuanzhi Li <

> Yuanzhi.Li@

> > wrote:
>> > hello,
>> >
>> > I had a problem with the function "bargraph.CI". "bargraph.CI" draws a
>> > figure according to the alphabet sequence of the factor used. For
>> example, I
>> > have a factor with for levels "CK", "N5", "N10", "N15", but the bars
>> appear
>> > in "CK","N10","N15","N5" order(alphabet sequence), but I want the bars
>> to
>> > appear  "CK", "N5", "N10", "N15"(treat level sequence). Do you have any
>> > ideas to realize the goal?
>> >
>> > Thank you!
>> >
>> >
>> > Yuanzhi
>> >
>> 
>> --
>> Sarah Goslee
>> http://www.functionaldiversity.org
>> 
>> ______________________________________________
>> 

> R-help@

>  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@

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

Hello, I make it according to your suggestion. Thank you!



--
View this message in context: http://r.789695.n4.nabble.com/bargraph-CI-tp4682029p4682040.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list