[R] Not getting correct graphs

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Mar 31 15:09:28 CEST 2012



On 31.03.2012 15:03, Bryan Hanson wrote:
> Attachments don't come through on this list.
>
> It would be helpful to know what you mean by "junk graphs".
>
> Your coding style is a little hard to follow as it is a mix of ->  and<- but I think you definitely have a problem in
>
>> for (i in refid)
>
> which should probably be
>
> for (i in 1:length(refid))


Never ever:

1. I believe that part is right, but we cannot know given the example is 
not reproducible.

2. If it was wrong, then use seq_along(refid) rather than 
1:length(refid) which is broken by design for length 0 objects.

Uwe Ligges





> HTH.  Bryan
>
> On Mar 31, 2012, at 6:16 AM, Sri krishna Devarayalu Balanagu wrote:
>
>> Hi all,
>> Can anybody debug the following programme, as I am getting some Junk graphs in the pdf.
>> Please find the attached raw data file.
>> Thank you
>> Regards
>> Rayalu
>>
>>
>> library(ggplot2)
>> setwd("D:\\General Check list")
>> library(RODBC)
>> conn<- odbcConnectExcel ("Book1.xls")
>> Orange1<- sqlFetch (conn, "Sheet3")
>> odbcClose(conn)
>> rm(conn)
>>
>> #CDAI Change
>> unique(Orange1$BSCHSTAT) ->  change
>> pdf("xxx.pdf")
>> for (j in 1:length(change)){
>> ((Orange1$BASCHGAUT == "8-item scale")&(Orange1$BSCHSTAT == change[j])) ->  b
>> FD<- Orange1[b, ]
>> unique(FD$REFID) ->  refid
>> for (i in refid)
>> {
>> Orange2<- FD[i == FD$REFID, ]
>> Orange2$ARM<- factor(Orange2$ARM)
>> unique(Orange2$BSCHSTAT) ->  x
>> y<- paste("REFID=", i,"; ", "BSCHSTAT=", x, sep="")
>> print(qplot(TIME1, BASCHGA, data=Orange2, geom= c("line", "point"), colour=ARM, main=y))
>> }
>> }
>> dev.off()
>>
>> ______________________________________________
>> R-help at 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 at 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.



More information about the R-help mailing list