Jan,
Thank you very much for the solution given. Still I am having one
more question.
I want both the graphs in single pdf and the legend should contain
ACTTRT of individual REFID (Only two lines in legend)
Can you solve it?
Devarayalu
-----Original Message-----
From: Jan van der Laan [mailto:rhelp at eoos.dds.nl]
Sent: Thursday, January 19, 2012 5:09 PM
To: Sri krishna Devarayalu Balanagu
Cc: r-help at r-project.org
Subject: Re: [R] Not generating line chart
Devarayalu,
Please reply to the list.
And it would have easier if you would have outputted your data using
dput (in your case dput(Orange1)) so that I and other r-help members
can just copy the data into R. Not everybody had Excell available (I
for example haven't). The easier you make it for people to look into
your problem, the higher the probability that you will get a usefull
answer. In your case your data is quite small, so using dput is no
problem.
To answer your question. Except for the probable error
refid <- unique(Orange2$REFID)
which should probably be
refid <- unique(Orange1$REFID)
and the fact that overwrite your files in the loop, I have no problem
generating the graphs. On my system the following code runs and
generates two graphs:
library(ggplot2)
Orange1 <- structure(list(REFID = c(7L, 7L, 7L, 7L, 7L, 7L, 7L, 7L, 9L,
9L, 9L, 9L), ARM = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L,
2L, 2L), SUBARM = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L), ACTTRT = structure(c(3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 1L,
1L, 2L, 2L), .Label = c("ABC", "DEF", "LCD", "Vehicle"), class = "factor"),
TIME1 = c(0L, 2L, 6L, 12L, 0L, 2L, 6L, 12L, 0L, 12L, 0L,
12L), ENDPOINT = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), .Label = "PGA", class = "factor"), BASCHGA = c(0L,
-39L, -47L, -31L, 0L, -34L, -25L, -12L, 0L, -30L, 0L, -40L
), STATANAL = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L), .Label = "UNK", class = "factor"), X = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), .Label = c("",
"Dansinger_2010_20687812"), class = "factor")), .Names = c("REFID",
"ARM", "SUBARM", "ACTTRT", "TIME1", "ENDPOINT", "BASCHGA", "STATANAL",
"X"), class = "data.frame", row.names = c(NA, -12L))
refid <- unique(Orange1$REFID)
for (i in refid)
{
Orange2 <- Orange1[i == Orange1$REFID, ]
pdf(paste('PGA', i, '.pdf', sep=''))
print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line"),
colour= ACTTRT))
dev.off()
}
Regards,
Jan
Sri krishna Devarayalu Balanagu <balanagudevarayulu at gvkbio.com> schreef: