[R-sig-ME] Library (lattice)

Joshua Wiley jwiley.psych at gmail.com
Tue Mar 22 05:02:54 CET 2011


Dear Shankar,

It seems like this is more of a question for R-help than mixed models,
but in any case, I think this does what you want.  See comments in the
code for explanation.


HTH,

Josh

############################
## Only using part of your data
dat <- read.table(textConnection("
ID  X    Y1  Y2
1  0.5  0.4   1
1  0.2  0.1   2
1  1      2    3
1  4      5    4
2  2.5   3    5
2  3      4    6
2  0.5  0.4   7
2  0.2  0.1   8
2   1      2   9
2   4      5   8
2  2.5   3    7
2  3      4    6
3  0.5  0.4  5
3  0.2  0.1  4"), header = TRUE)
closeAllConnections()

## Sorting will making the lines prettier
dat <- dat[order(dat$ID, dat$X), ]
## Convert ID to a factor to show its labels
dat$ID <- factor(dat$ID)

require(lattice)
## type = "l" specifies lines rather than points
xyplot(log(Y1) + log(Y2) ~ X | ID, data = dat, type = "l",
  layout=c(0,4))
############################

On Mon, Mar 21, 2011 at 8:16 PM, Shankar Lanke <shankarlanke at gmail.com> wrote:
>>
>> Dear All,
>>
>
>
>> I am looking for a code to plot X and Multiple Y scatter plot.(Table
>> below). I used the following R-Code ,however I am unable to figure out how
>> to plot lines plot for Y1 and show the ID number on top of each plot.
>>
>
>> library("lattice")
>> xyplot(log(Y1)+log(Y2)~X|ID,layout=c(0,4))
>
>>
>> ID  X    Y1  Y2
>> 1  0.5  0.4   1
>> 1  0.2  0.1   2
>> 1  1      2    3
>> 1  4      5    4
>> 2  2.5   3    5
>> 2  3      4    6
>> 2  0.5  0.4   7
>> 2  0.2  0.1   8
>> 2   1      2   9
>> 2   4      5   8
>> 2  2.5   3    7
>> 2  3      4    6
>> 3  0.5  0.4  5
>> 3  0.2  0.1  4
>> 3  1      2
>> 3   4      5
>> 3  2.5   3
>> 3  3      4
>>
>> Thank you very much for your suggestions.
>>
>
> Regards,
> Shankar Lanke Ph.D.
> University at Buffalo
> Office # 716-645-4853
> Fax # 716-645-2886
> Cell # 678-232-3567
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/




More information about the R-sig-mixed-models mailing list