[R] Scale y-labels based on a value with 'lattice'

Jim Lemon drjimlemon at gmail.com
Fri May 27 00:08:48 CEST 2016


Hi Kimmo,
I was unable to work out how to do this in lattice, but this might help:

kedf<-read.table(text="Group.1    Group.2     x Freq
 deutschland  achtziger  2.00    1
 deutschland        alt  1.25    4
 deutschland     anfang -2.00    1
 deutschland    ansehen  1.00    2
 deutschland     arbeit  0.50    2
 deutschland arbeitslos -2.00    1",header=TRUE)

par(mar=c(5,7,4,2))
dotchart(kedf$x)
mtext(kedf$Group.2,side=2,at=1:6,line=0.5,
 las=2,cex=log(abs(kedf$Freq))+1)

Jim


On Fri, May 27, 2016 at 12:51 AM, K. Elo <maillists at pp.inet.fi> wrote:
> Dear R-helpers!
>
> I have a data frame storing data for word co-occurrences, average distances
> and co-occurence frequency:
>
>       Group.1    Group.2     x Freq
> 1 deutschland  achtziger  2.00    1
> 2 deutschland        alt  1.25    4
> 3 deutschland     anfang -2.00    1
> 4 deutschland    ansehen  1.00    2
> 5 deutschland     arbeit  0.50    2
> 6 deutschland arbeitslos -2.00    1
>
> Now I want to plot a lattice 'dotplot' with the formula 'Group.2~x'. This
> works fine.
>
> However, I would like to scale the y-label (based on 'Group.2' according the
> 'Freq' value using a log-scaled value (log(Freq+.5)). In other words: the
> higher the 'Freq' value of a term, the bigger its label should be printed in
> my dotplot.
>
> The problem is that I cannot figure out how to tell lattice to scale each
> y-label with according 'Freq' value. I am quite sure I should build a
> function for scales=list(y=...), but I don't know how to it.
>
> Many thanks in advance for your help!
>
> Best,
> Kimmo Elo
>
> --
> Åbo Akademi University / German studies
> Turku, Finland
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list