[R] Manipulating x axis in stripchart

Gabor Grothendieck ggrothendieck at gmail.com
Wed Nov 21 04:22:32 CET 2007


If its ok to use lattice try this:

library(lattice)

# no attach needed

# we want VC to be first level, not OJ
ToothGrowth$supp <- relevel(ToothGrowth$supp, "VC")

# rename levels
levels(ToothGrowth$supp) <- c("A", "B")

# plot
dotplot(len ~ supp | dose, ToothGrowth, layout = c(3, 1))


On Nov 20, 2007 10:04 PM, Judith Flores <juryef at yahoo.com> wrote:
> Hi all,
>
>   I I need to manipulate the x axis in a stripchart.
> I will use one of the data sets included in R to
> explain what I need to do.
>
> attach(ToothGrowth)
>
> stripchart(len[supp=='VC']~dose[supp=='VC'],
> vertical=TRUE, group.names=c('A','A','A'))
>
> stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
> vertical=TRUE, at=c(1:3)+.1,
> group.names=c('B','B','B'))
>
> As you can read from the code above, I wanted to add
> the 'B' to the x axis to diffrenciate each pair of
> strips from each other. But only the 'A's appear.
>
> I tried something like this too, but now '.5','1' and
> '2' along with the 'A' and 'B'.
>
> attach(ToothGrowth)
>
> stripchart(len[supp=='VC']~dose[supp=='VC'],
> vertical=TRUE)
> axis(side=1,labels=c('A','B','A','B','A','B'),
> at=c(.4,.5,.9,1.1,1.9,2.1))
>
>
> stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
> vertical=TRUE, at=c(1:3)+.1)
>
> And finally I tried setting par(xaxt='n') before
> stripchart, but then I can't add anything to the x
> axis.
>
>  Is there a way to manipulate the x axis in a
> stripchart like this?
>
> Thank you very much in advance for your help,
>
> Judith
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list