monkeymike.co.uk

May 12, 2010

sql access part 2 with boxplot and big query

Filed under: R hints and Tips — @ 8:05 pm

##load the required bits
library(RODBC)
library(lattice)
##set up the connection
channel<-odbcConnect("mike_db", uid="mike")
##sqlTables(channel)
##a<-sqlFetch(channel,"AnE")
##b<-sqlFetch(channel,"vwAnE")
##b<-sqlQuery(channel, paste("select * from vwAnE order by loc, month_val"))
##xyplot(N~month_val|LOC,b, type="l")

##c<-sqlQuery(channel, paste("select CM,sum(numerator)"
## ,"from EP_2010_2011_ENHANCED"#
## , "WHERE not parnt like 'z_%' "
## ," group by CM"
## ))

##execute a query for the data
e<-sqlQuery(channel, paste("select CM,aggregate_02,spect,Numerator,denominator,value,target, year_month+'-01' as year_month"
,"from EP_2010_2011_ENHANCED"
,"where 1=1 and CM like '%e_01%'and TIME_TYPE='per-month'"
,"and parnt like 'z_t%'order by aggregate_02,spect,year_month"))
##convert the year_month value to a date

e$year_month<-as.Date(e$year_month)

##plot the lattice

xyplot(value~year_month|spect,e, type="l", cex=3)

xyplot(value+target~year_month|spect,e, type="l", size=5)

1 Comment »

  1. ?? ???? ????!…

    ….

    Trackback by Kylie Batt — May 24, 2010 @ 5:31 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress