Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

larrows error inside panel.groups function #39

Open
@gavril0

Description

@gavril0

I get an error with when plotting confidence intervals withlarrows in a plot with a grouping variable (but it works withlsegments).

newdat <- read.table(text="    age    Sex distance     pvar1    tvar1      thi       tlo     8 Female 21.20909 0.4030807 6.177568 33.31712  9.101058    10 Female 22.16818 0.3418827 6.116370 34.15627 10.180096    12 Female 23.12727 0.3667087 6.141196 35.16402 11.090529    14 Female 24.08636 0.4775585 6.252046 36.34037 11.832354     8   Male 22.61563 0.2771180 6.051605 34.47677 10.754479    10   Male 24.18438 0.2350444 6.009532 35.96306 12.405693    12   Male 25.75312 0.2521122 6.026600 37.56526 13.940990    14   Male 27.32187 0.3283215 6.102809 39.28338 15.360370  ", header=TRUE)

I get the desired plot when the vertical bars are drawn withpanel.segments:

xyplot(distance ~ age, group= Sex, data=newdat, ylim=c(0,50),   panel = panel.superpose.2, col=c("red","blue"),   panel.groups = function (x,y, lx, ux, subscripts, group.value, ...){     x <- if(group.value=="Male") x - 0.1 else x + 0.1     panel.xyplot(x,y,...)     panel.segments(x0 = x,  y0 = lx[subscripts], x1 = x, y1 = ux[subscripts], ...)#    panel.arrows(x0 = x,  y0 = lx[subscripts], x1 = x, y1 = ux[subscripts], ...)   },  lx=newdat$tlo, ux=newdat$thi)

image

but not withpanel.arrows:

xyplot(distance ~ age, group= Sex, data=newdat, ylim=c(0,50),   panel = panel.superpose.2, col=c("red","blue"),   panel.groups = function (x,y, lx, ux, subscripts, group.value, ...){     x <- if(group.value=="Male") x - 0.1 else x + 0.1     panel.xyplot(x,y,...)#   panel.segments(x0 = x,  y0 = lx[subscripts], x1 = x, y1 = ux[subscripts], ...)    panel.arrows(x0 = x,  y0 = lx[subscripts], x1 = x, y1 = ux[subscripts], ...)   },  lx=newdat$tlo, ux=newdat$thi)

=>Errors using packet 1: invalid 'ends' or 'type' argument

I have tried to specify arrows arguments (ends,length,angle) but it does not help. Note that the functionlarrows works in the panel function:

xyplot(distance ~ age | Sex, data=newdat,  ylim=c(0,50),    panel = function (x,y, lx, ux, subscripts, ...) {     panel.xyplot(x,y,...)      panel.arrows(x0 = x,  y0 = lx[subscripts], x1 = x, y1 = ux[subscripts],       ends="both", length=0.1, angle=90, ...)   },  lx=newdat$tlo, ux=newdat$thi)

image

Session info:R version 4.3.1, lattice_0.21-8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp