yes exactly

thank you Peter

On Sun, Jan 30, 2011 at 2:24 PM, Peter Ehlers <ehl...@ucalgary.ca> wrote:

> On 2011-01-26 04:56, Christophe Bouffioux wrote:
>
>> Hello everybody,
>>
>> i need some help to display text as label in my barchart
>> the label is the combination of x value + text
>> text= calculated percentage =>  per
>> it display properly the x value
>> but, wrongly repeats the text of the fisrt level LangueTXT factor on the
>> second
>>
>> any solution?
>> Thanx very much
>> Christophe
>>
>>
>> ######## here is the code ##########
>> library(lattice)
>> Langue<- c(1, 1, 1, 2, 2, 2, 2)
>> n03interessantscore<- c(1, 2, 3, 1, 2, 3, 4)
>> count<- c(89, 148, 16, 88, 192, 28, 7)
>> sumcount<- c(253, 253, 253, 315, 315, 315, 315)
>> per<- c('35.2%','58.5%','6.3%','27.9%','61%','8.9%','2.2%')
>> LangueTXT<- c('Nl','Nl','Nl','Fr','Fr','Fr','Fr')
>>
>>
>> databar<- data.frame(Langue, n03interessantscore, count, sumcount, per,
>> LangueTXT)
>>
>> barchart(n03interessantscore ~ count| LangueTXT, data=databar,
>>          layout=c(1,max(databar$Langue)), stack=TRUE, rectangles=TRUE,
>> horizontal=TRUE,
>>          ylab="Score",
>>          xlab="Count",
>>          col="grey",
>>          main="3.0z Trouvez-vous ce rapport intéressant?",
>>          border="NA",
>>          panel= function(y,x,...){panel.grid(h=0, v=-1, col="gray")
>>          Y<- tapply(y, y, unique)
>>           panel.barchart(x,y,...)
>>           panel.text((x-0.1*x), Y, label= paste(round(x,0),'-',
>> databar$per), cex=0.9)}
>>          )
>>
>>
> I haven't seen an answer to this yet.
> You need subscripts; replace
>
>  panel= function(y,x,...){
>
> with
>
>  panel = function(x, y, subscripts, ...){
>
> and
>
>  databar$per
>
> with
>
>  databar$per[subscripts]
>
>
> Peter Ehlers
>

        [[alternative HTML version deleted]]

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

Reply via email to