Variable names in lattice XY-plot

4 messages Options
Embed this post
Permalink
ukoenig

Variable names in lattice XY-plot

Reply Threaded More More options
Print post
Permalink
Hi,
how can I get a more descriptive text
instead of the variable names in my XY-lattice plot,
according to the table below?

Variable    text
acet     = "Acetylaspartate Thalamus"
chol     = "Choline Thalamus"
acetp    = "Acetylaspartate parieoc"
ino      = "Inositole Thalamus"


I could not find a solution.
Please have a look at my syntax.
Thanks a lot,
Udo



library(lattice)

grp <-c(0,1,0,1)
zp <- c(1,1,2,2)
acet <- c(1.7,1.8,1.9,1.8)
chol <- c(0.6, 0.8,0.8, 0.7)
ino <- c(0.6, 0.3, 0.5, 0.4)
acetp <- c(1.8, 1.9, 2.0, 1.8)

data <- data.frame(cbind(grp, zp, acet, chol, ino, acetp))
data$grp <- factor(data$grp)
levels(data$grp) <- c("low","high")


xyplot(acet+chol+ino+acetp ~ zp,
        group=grp,
        data=data,
        type="l",
        scales=list(relation="free"),
        auto.key=list(title="Neurotransmitters", border=TRUE))

______________________________________________
[hidden email] 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.
baptiste auguie-5

Re: Variable names in lattice XY-plot

Reply Threaded More More options
Print post
Permalink
?strip.custom


p <-
xyplot(acet+chol+ino+acetp ~ zp,
      group=grp,
      data=data,
      type="l",
      scales=list(relation="free"),
      auto.key=list(title="
>
> Neurotransmitters", border=TRUE))



update(p, strip=strip.custom(factor.levels=letters[1:4]))


HTH,

baptiste


2009/7/3 <[hidden email]>

> Hi,
> how can I get a more descriptive text
> instead of the variable names in my XY-lattice plot,
> according to the table below?
>
> Variable    text
> acet     = "Acetylaspartate Thalamus"
> chol     = "Choline Thalamus"
> acetp    = "Acetylaspartate parieoc"
> ino      = "Inositole Thalamus"
>
>
> I could not find a solution.
> Please have a look at my syntax.
> Thanks a lot,
> Udo
>
>
>
> library(lattice)
>
> grp <-c(0,1,0,1)
> zp <- c(1,1,2,2)
> acet <- c(1.7,1.8,1.9,1.8)
> chol <- c(0.6, 0.8,0.8, 0.7)
> ino <- c(0.6, 0.3, 0.5, 0.4)
> acetp <- c(1.8, 1.9, 2.0, 1.8)
>
> data <- data.frame(cbind(grp, zp, acet, chol, ino, acetp))
> data$grp <- factor(data$grp)
> levels(data$grp) <- c("low","high")
>
>
> xyplot(acet+chol+ino+acetp ~ zp,
>       group=grp,
>       data=data,
>       type="l",
>       scales=list(relation="free"),
>       auto.key=list(title="Neurotransmitters", border=TRUE))
>
> ______________________________________________
> [hidden email] 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.
>


--

_____________________________

Baptiste AuguiƩ

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] 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.
Deepayan Sarkar

Re: Variable names in lattice XY-plot

Reply Threaded More More options
Print post
Permalink
On Fri, Jul 3, 2009 at 1:02 PM, baptiste
auguie<[hidden email]> wrote:

> ?strip.custom
>
>
> p <-
> xyplot(acet+chol+ino+acetp ~ zp,
>      group=grp,
>      data=data,
>      type="l",
>      scales=list(relation="free"),
>      auto.key=list(title="
>>
>> Neurotransmitters", border=TRUE))
>
>
>
> update(p, strip=strip.custom(factor.levels=letters[1:4]))

Or,

> dimnames(p)
[[1]]
[1] "acet"  "chol"  "ino"   "acetp"
> dimnames(p)[[1]]
[1] "acet"  "chol"  "ino"   "acetp"
> dimnames(p)[[1]] <- c("Acetylaspartate Thalamus", "Choline Thalamus", "Acetylaspartate parieoc", "Inositole Thalamus")
> p

which is more easily generalizable when more than one conditioning
variable is involved.

-Deepayan

______________________________________________
[hidden email] 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.
ukoenig

Re: Variable names in lattice XY-plot

Reply Threaded More More options
Print post
Permalink
Thanks a lot
Baptiste and Deepayan!

That was very helpful-things can be so easy...

-Udo


Quoting Deepayan Sarkar <[hidden email]>:

> On Fri, Jul 3, 2009 at 1:02 PM, baptiste
> auguie<[hidden email]> wrote:
>> ?strip.custom
>>
>>
>> p <-
>> xyplot(acet+chol+ino+acetp ~ zp,
>>      group=grp,
>>      data=data,
>>      type="l",
>>      scales=list(relation="free"),
>>      auto.key=list(title="
>>>
>>> Neurotransmitters", border=TRUE))
>>
>>
>>
>> update(p, strip=strip.custom(factor.levels=letters[1:4]))
>
> Or,
>
>> dimnames(p)
> [[1]]
> [1] "acet"  "chol"  "ino"   "acetp"
>> dimnames(p)[[1]]
> [1] "acet"  "chol"  "ino"   "acetp"
>> dimnames(p)[[1]] <- c("Acetylaspartate Thalamus", "Choline  
>> Thalamus", "Acetylaspartate parieoc", "Inositole Thalamus")
>> p
>
> which is more easily generalizable when more than one conditioning
> variable is involved.
>
> -Deepayan
>

______________________________________________
[hidden email] 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.