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 <balanagudevaray...@gvkbio.com> schreef:

Jan

Thank you, for your valuable reply. But...

Sorry still I am not getting by using print() with the following modified code. I am also attaching the raw datafile.


par(mfrow=c(1,3))

#qplot(TIME1, BASCHGA, data=Orange1, geom= c("point", "line"), colour= ACTTRT)
unique(Orange1$REFID) -> refid
for (i in refid)
{
Orange2 <- Orange1[i == Orange1$REFID, ]
pdf('PGA.pdf')
print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line"), colour= ACTTRT))
dev.off()
}
Regards
Devarayalu





-----Original Message-----
From: Jan van der Laan [mailto:rh...@eoos.dds.nl]
Sent: Thursday, January 19, 2012 4:25 PM
To: Sri krishna Devarayalu Balanagu
Cc: r-help@r-project.org
Subject: Re: [R] Not generating line chart

Devarayalu,

This is FAQ 7.22:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f

use print(qplot(....))

Regards,
Jan


Sri krishna Devarayalu Balanagu <balanagudevaray...@gvkbio.com> schreef:

Hi All,


Can you please help me, why this code in not generating line chart?



library(ggplot2)
par(mfrow=c(1,3))

#qplot(TIME1, BASCHGA, data=Orange1, geom= c("point", "line"),
colour= ACTTRT)
unique(Orange1$REFID) -> refid
for (i in refid)
{
Orange2 <- Orange1[i == Orange1$REFID, ]
pdf('PGA.pdf')
qplot(TIME1, BASCHGA, data=Orange2, geom= c("line"), colour= ACTTRT)
dev.off()
}
Regards,
Devarayalu

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to