maneesh@www.chip.org
2001-Jul-17 22:19 UTC
[R] some newbie problems with plotting and RPgSQL
Dear R-enthusiasts, What a wonderful package R is, many thanks to all you have contributed (I've just started using it)...I have a few questions that I am having some trouble finding the answer to: I am using RPgSQL to grab some data from a postgresql database (about 179 columns and a few thousand rows), and I want to do a lot of pairwise comparison of the rows...(this is yeast genomic microarray data for those who care) I get to the database:> db.connect(dbname="yeast")and grab the first two rows like this:> t<-sql.select(columns="*", from="gasch", limit=2)then create two lists a la:> a<-t[1,][4:length(t[1,])] > b<-t[2,][4:length(t[2,])](the first 3 entries are text) and now I just want to see a plot(a,b) but I always get the following error: Error in plot.new() : Figure margins too large (I even tried par(mar=c(0,0,0,0))) Oddly I get the following behaviour:> plot(seq(1,174),a)works (the graph looks like it should) but the reverse> plot(a,seq(1,174))gives me: Error in plot.new() : Figure margins too large similarly for b...so I am guessing the problem is passing my lists as the first argument... Manually getting the rows and making a text file that explictly states the vectors and then sourcing the file from R does plot(a,b) just fine.... If I understand the R classes correctly t is a dataframe and a and b are lists (named by the column headings of the database).... I'm sure there is something stupid I am doing.... Also I am little confused as to the meaning of t[0,] when I get the data.frame back from my SQL query, if anyone happens to have any insight. Many thanks, Maneesh (please email to this address as I am not subscribed to the list) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi> I am using RPgSQL to grab some data from a postgresql database (about 179 > columns and a few thousand rows), and I want to do a lot of pairwise > comparison of the rows...(this is yeast genomic microarray data for those > who care) > > I get to the database: > > > db.connect(dbname="yeast") > > and grab the first two rows like this: > > > t<-sql.select(columns="*", from="gasch", limit=2) > > then create two lists a la: > > > a<-t[1,][4:length(t[1,])] > > b<-t[2,][4:length(t[2,])] > > (the first 3 entries are text) > > and now I just want to see a plot(a,b) but I always get the following > error: > > Error in plot.new() : Figure margins too large > > (I even tried par(mar=c(0,0,0,0))) > > Oddly I get the following behaviour: > > > plot(seq(1,174),a) > > works (the graph looks like it should) > > but the reverse > > > plot(a,seq(1,174)) > > gives me: > > Error in plot.new() : Figure margins too large > > similarly for b...so I am guessing the problem is passing my lists as the > first argument... > > Manually getting the rows and making a text file that explictly states the > vectors and then sourcing the file from R does plot(a,b) just fine.... > > If I understand the R classes correctly t is a dataframe and a and b are > lists (named by the column headings of the database)....I don't think so. A subset of the rows of a data.frame is still a data.frame ... > temp <- data.frame(x=1:10, y=10:1) > class(temp[1,]) [1] "data.frame" This means that plot(a, <whatever>) or plot(b, <whatever>) is going to call the plot.data.frame() method. This is going to try to do a pairs() plot with 174*174 plots :) Hence the error message that there is not enough room to draw the plots. Note that plot(1:174, a) will work because method dispatching (mostly) works on the first argument to the function. That is, plot(1:174, <whatever>) does a default plot because 1:174 has no class, but plot(<something of class "data.frame">, <whatever>) does a special plot designed for data frames. Here's a simple toy example, ... > x <- 1:10 > class(x) <- "test" > plot.test <- function(x, y) { cat("A custom plot") } > plot(1:10, x) # produces a default scatterplot > plot(x, 1:10) A custom plot > Hope that helps. Paul -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._