[R] overlaying a set of 'grouping' lines on a plot from image()
05, -0.589916523116354, -0.00372212162890484, -5999, -5999, -23.4849997880608, -5999, -5999, -5999, -5999, -5999, -1.86547984241505, -0.026350603161482, -0.02093102809318, -0.104903640669956, -5999), .Dim = c(55L, 6L), .Dimnames = list( c("170", "150", "283", "118", "292", "293", "307", "374", "443", "151", "18", "44", "276", "387", "411", "388", "259", "458", "261", "146", "108", "433", "95", "99", "301", "80", "193", "77", "233", "234", "241", "242", "217", "122", "254", "414", "184", "184.1", "13", "28", "64", "213", "215", "216", "86", "79", "88", "128", "29", "218", "263", "329", "123", "3", "121"), c("Col1", "Col2", "Col3", "Col4", "Col5", "Col6" ))) cols <- c("#00", "#19", "#33", "#4C", "#66", "#7F", "#99", "#B2", "#CC", "#E5", "#FF", "#00FF00", "#00AA00", "#005500", "#00") br <- c(-6000, -10, -1, -0.889, -0.778, -0.667, -0.556, -0.444, -0.333, -0.222, -0.111, 0, 0, 1, 10, 6000) m <- t(m[nrow(m):1,ncol(m):1]) par(las=2, mar=c(8,8,1,1)) image(t(m), ylab='', xlab='', axes=FALSE, col=cols, breaks=br, useRaster=FALSE) axis(2, at=seq(0,1,length=6), labels=rownames(m), font=2) axis(1, labels = FALSE, tick=FALSE) labels <- sprintf("Compound%d", 1:ncol(m)) text(seq(0, 1, length=ncol(m)), par("usr")[3] - 0.1, srt = 45, adj = 1, labels = labels, xpd = TRUE, col='#66', cex=0.8) -- Rajarshi Guha | http://blog.rguha.net NIH Center for Advancing Translational Science __ 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] strange differences in vector operation versus manual calculation
Hi, I'm running a calculation in two ways. The first way is to employ vectors and evaluate a function in one go. The second way is to break down the function into pieces and combine the pieces to the final answer. Algebraically, they should give me the same result. But the final vector differs significantly. I must be missing something very obvious, but I just cannot see it xx <- c(-9.56305825951348, -8.20220288142583, -6.84134750333818, -5.48049212525052, -4.11963674716287) params <- structure(c(-7.9292094394, 4.9549173134, 4.738588416, 101.5743644892 ), .Names = c("LOG_AC50", "HILL_COEF", "INF_ACTIVITY", "ZERO_ACTIVITY" )) yy <- params[4] + (params[3] - params[4])/(1 + 10^(params[1]-xx)^params[2]) t1 <- 10^(params[1]-xx) t2 <- params[3] - params[4] t3 <- (1+t1)^params[2] t4 <- t2/t3; t5 <- params[4] + t4 I would've expected yy and t5 to be the same; yet they are not -- Rajarshi Guha | http://blog.rguha.net NIH Center for Advancing Translational Science __ 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] prevent export of specific functions in NAMESPACE
Hi, I'd like to prevent the export a specific function in the NAMESPACE file. The example in the R documentation uses a regex to prevent export of a set of functions, but as far as I can see there is no easy way to specify that a function of a specific name should not be exported. This thread (http://www.mail-archive.com/r-help@r-project.org/msg42961.html) suggests that a regex is not the way to 'negate' a string literal. So to prevent export of specific functions, do I need to explicitly list all functions that are to be exported? -- Rajarshi Guha NIH Chemical Genomics Center __ 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] arranging pie charts in a matrix layout with row/col labels
Hi, I have a vector of data, that I group based on two factors via tapply. For each such grouping I would like to plot a pie chart. I can layout these pie charts in a matrix layout, correpsonding to the levels of the two factors. But I am getting stuck on how to label the rows and colums. My current approach looks like this: x <- data.frame(obs=sample(c('low', 'high'),100, replace=TRUE), grp1=sample(1:10, 100, replace=TRUE), grp2=runif(100)) cut.grp1 <- cut(x$grp1, 3) cut.grp2 <- cut(x$grp2, 3) par(mfrow=c(3,3)) tapply(x$obs, list(cut.grp1, cut.grp2), function(z) { pie(table(z), col=c('red', 'green')) }) One possibility is to add an extra row and column to the layout and loop over the results of the tapply, adding a text label for the row and column labels. Is there a better way to achieve this? -- Rajarshi Guha NIH Chemical Genomics Center __ 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.
Re: [R] identify subsets based on two grouping factors
Indeed, tapply is what I needed. To clarify Phils' question, what I needed was tapply(x, list(cut.grp1, cut.grp2), function(z) table(z)) On Mon, Jan 31, 2011 at 4:50 PM, Bert Gunter wrote: > ?tapply is the basic R function for this. There are many other packages > (e.g. plyr) and functions (e.g. ave) that simplify and streamline this for > more complicated applications. > > -- Bert > > On Mon, Jan 31, 2011 at 1:43 PM, Rajarshi Guha > wrote: >> >> Hi, I have a data.frame that has a categorical variable, for which I >> would like to look at the distribution of levels of this variable, >> based on a grouping of two other variables. >> >> As an example: >> >> x <- data.frame(obs=sample(c('low', 'high'),100, replace=TRUE), >> grp1=sample(1:10, 100, replace=TRUE), >> grp2=runif(100)) >> >> cut.grp1 <- cut(x$grp1, 3) >> cut.grp2 <- cut(x$grp2, 3) >> >> Thus, for each combination of levels in cut.grp1 and cut.grp2, I'd >> like to obtain the distribution of levels obs. I know I can loop over >> each pair of levels in cut.grp1 and cut.grp2, but is there a more >> elegant way to achieve this? >> >> -- >> Rajarshi Guha >> NIH Chemical Genomics Center >> >> __ >> 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. > > > > -- > Bert Gunter > Genentech Nonclinical Biostatistics > 467-7374 > http://devo.gene.com/groups/devo/depts/ncb/home.shtml > -- Rajarshi Guha NIH Chemical Genomics Center __ 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] identify subsets based on two grouping factors
Hi, I have a data.frame that has a categorical variable, for which I would like to look at the distribution of levels of this variable, based on a grouping of two other variables. As an example: x <- data.frame(obs=sample(c('low', 'high'),100, replace=TRUE), grp1=sample(1:10, 100, replace=TRUE), grp2=runif(100)) cut.grp1 <- cut(x$grp1, 3) cut.grp2 <- cut(x$grp2, 3) Thus, for each combination of levels in cut.grp1 and cut.grp2, I'd like to obtain the distribution of levels obs. I know I can loop over each pair of levels in cut.grp1 and cut.grp2, but is there a more elegant way to achieve this? -- Rajarshi Guha NIH Chemical Genomics Center __ 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.
Re: [R] adding text to the top corner of a lattice plot
This (and Gabors) solutions work great. Thanks to everybody for helping out On Fri, Dec 17, 2010 at 1:24 AM, David Winsemius wrote: > > On Dec 17, 2010, at 12:07 AM, Rajarshi Guha wrote: > >> On Thu, Dec 16, 2010 at 11:26 PM, David Winsemius >> wrote: >>> >>> On Dec 16, 2010, at 11:12 PM, Rajarshi Guha wrote: >>> >>>> Hi, I have a series of lattice plots which I am arranging in a 2x2 >>>> grid via print: >>>> >>>> print(p.preds, split=c(1,1, 2,2), more=TRUE) >>>> print(p.comp, split=c(2,1,2,2), more=TRUE) >>>> print(p.bw, split=c(1,2,2,2), more=FALSE) >>>> >>>> What I'd like to have is a letter (A, B, ...) in the top corner of >>>> each plot. While panel.text lets me add text anywhere within a plot, I >>>> can't seem to workout how I could put some text in the top left >>>> corner, say, of the whole plotting region. >>> >>> >>>>>>>>> >>>> >>>> and provide commented, minimal, self-contained, reproducible code. >> >> Apologies for an incomplete post. Example code, based on Gabors suggestion >> is >> >> library(gridExtra) >> p1 <- xyplot(demand ~ Time, BOD) >> p2 <- xyplot(demand ~ Time, BOD) >> p3 <- xyplot(demand ~ Time, BOD) >> print(p1, split=c(1,1,2,2), more=TRUE) >> print(p2, split=c(2,1,2,2), more=TRUE) >> print(p3, split=c(1,2,2,2), more=FALSE) >> >> However, Gabors approach places the mark within the plot itself. What >> I'd ideally like is to have the mark be located in the margins, in the >> top right corner. (I am not sure of the correct terminology here). An >> example of the desired output can be seen at >> http://rguha.net/plot-annot.png >> > > Something along these lines? > > vp <- viewport(w = 1, h = 1, gp = gpar(col="blue")) # or "black" > grid.text("A", > y = .95, x=.05, > gp = gpar(fontsize=20), vp = vp) > grid.text("B", > y = .95, x=.55, > gp = gpar(fontsize=20), vp = vp) > grid.text("C", > y = .45, x=.05, > gp = gpar(fontsize=20), vp = vp) > -- > > David Winsemius, MD > West Hartford, CT > > -- Rajarshi Guha NIH Chemical Genomics Center __ 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.
Re: [R] adding text to the top corner of a lattice plot
On Thu, Dec 16, 2010 at 11:26 PM, David Winsemius wrote: > > On Dec 16, 2010, at 11:12 PM, Rajarshi Guha wrote: > >> Hi, I have a series of lattice plots which I am arranging in a 2x2 >> grid via print: >> >> print(p.preds, split=c(1,1, 2,2), more=TRUE) >> print(p.comp, split=c(2,1,2,2), more=TRUE) >> print(p.bw, split=c(1,2,2,2), more=FALSE) >> >> What I'd like to have is a letter (A, B, ...) in the top corner of >> each plot. While panel.text lets me add text anywhere within a plot, I >> can't seem to workout how I could put some text in the top left >> corner, say, of the whole plotting region. > >>>>>>>>> >> >> and provide commented, minimal, self-contained, reproducible code. Apologies for an incomplete post. Example code, based on Gabors suggestion is library(gridExtra) p1 <- xyplot(demand ~ Time, BOD) p2 <- xyplot(demand ~ Time, BOD) p3 <- xyplot(demand ~ Time, BOD) print(p1, split=c(1,1,2,2), more=TRUE) print(p2, split=c(2,1,2,2), more=TRUE) print(p3, split=c(1,2,2,2), more=FALSE) However, Gabors approach places the mark within the plot itself. What I'd ideally like is to have the mark be located in the margins, in the top right corner. (I am not sure of the correct terminology here). An example of the desired output can be seen at http://rguha.net/plot-annot.png -- Rajarshi Guha NIH Chemical Genomics Center __ 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] adding text to the top corner of a lattice plot
Hi, I have a series of lattice plots which I am arranging in a 2x2 grid via print: print(p.preds, split=c(1,1, 2,2), more=TRUE) print(p.comp, split=c(2,1,2,2), more=TRUE) print(p.bw, split=c(1,2,2,2), more=FALSE) What I'd like to have is a letter (A, B, ...) in the top corner of each plot. While panel.text lets me add text anywhere within a plot, I can't seem to workout how I could put some text in the top left corner, say, of the whole plotting region. Any pointers would be appreciated -- Rajarshi Guha NIH Chemical Genomics Center __ 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] rasterImage and coordinate conversion
Hi, I have a plot and I would like to overlay a PNG image over it. I'm using the rasterImage function to do this, but the problem I'm facing is working out the coordinates of the upper right corner of the final image in user coordinates. That is I can place the image so the lower left is located at the bottom of the y-axis and the left end of the x-axis. Since my image is say 100px x 100px, is there a way for me to convert a 100px length into the appropriate value in user coordinates, along the x-axis? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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.
Re: [R] Pipeline pilot fingerprint package
On Tue, Oct 12, 2010 at 8:54 PM, Eric Hu wrote: > Hi, > > I am trying to see if I can use R to perform more rigorous regression > analysis. I wonder if the fingerprint package is able to handle pipeline > pilot fingerprints (ECFC6 etc) now. Currently no - does Pipeline Pilot out put their ECFP's in a standard format? if so can you send me an example file? (Asuming they output fp's for a single molecule on a single row, you could implement your own line parse and supply it via the lf argument in fp.read. See cdk.lf, moe.lf or bci.lf for examples) The other issue is how one evaluates similarity between variable length feature fingerprints, such as ECFPs. One approach is to map the features into a fixed length bit string. Another approach is to just look at intersections and unions of features to evaluate the Tanimoto score. It seems to me that the former leads to loss of resolution and that the latter could lead to generally low Tanimoto scores. Do you know what Pipeline Pilot does? -- Rajarshi Guha NIH Chemical Genomics Center __ 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] sorting a (homogenous) list of objects, based on a a field of the objects
Him I have a list of S4 objects. Each object has a field called name, and what I'd like to do is to sort the list based on the value of name. Currently I'm using the following code tmp <- unlist(lapply(fps, function(x) as.integer(x...@name))) tmp <- order(tmp, decreasing=FALSE) fps <- fps[ tmp ] this seems a little klunky and I was wondering if there was another way to do this (by analogy with comparator functions in Java) Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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.
Re: [R] xyplot with all columns of a data.frame on a single plot
Thanks to everybody for the solutions. On Tue, Jul 27, 2010 at 3:47 AM, Dennis Murphy wrote: > Hi: > > Another approach might be to use the melt() function in package reshape > before creating the plot with xyplot, something along the lines of the > following: > > library(reshape) > mdat <- melt(data, id = 'X') > > This should create a data frame with three columns: X, variable (all the D* > names as factor levels) and value (stacked version of the D*s). Then use > something like > > xyplot(value ~ X, data = mdat, groups = 'variable', ...) > xyplot(value ~ X | variable, data = mdat, ...) > > One advantage of this approach is that you'll get the same structure out of > melt() no matter how many D* columns you have; > another is that the code block is small and relatively easy to remember six > months from now. Here's a simple toy example: > > library(reshape) > library(lattice) > d <- data.frame(x = 1:20, y1 = rnorm(20), y2 = rnorm(20), y3 = rnorm(20)) > > # Reshape the data: > m <- melt(d, id = 'x') > > # xyplot with a basic legend > > # melted data > xyplot(value ~ x, data = m, groups = variable, > auto.key = list(space = 'right', points = TRUE, lines = FALSE)) > # plot from the original data > xyplot(y1 + y2 + y3 ~ x, data = d, > auto.key = list(space = 'right', points = TRUE, lines = FALSE)) # > identical except for y label > > HTH, > Dennis > > On Mon, Jul 26, 2010 at 7:26 PM, Rajarshi Guha > wrote: >> >> Hi, I have a data.frame with columns named X, D1, D2, D3 >> >> I know I can get a single plot with 3 curves by doing >> >> xyplot(D1 + D2 + D3 ~ X, data) >> >> but in some cases I might have columns D1 ... D10. >> >> Is there a way to plot all 10 columns without having to specify each >> individual term? >> >> (By analogy with formulae in lm, I thought, xyplot(. ~ X, data) would >> work, but it didn't) >> >> Thanks, >> >> -- >> Rajarshi Guha >> NIH Chemical Genomics Center >> >> __ >> 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. > > -- Rajarshi Guha NIH Chemical Genomics Center __ 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] xyplot with all columns of a data.frame on a single plot
Hi, I have a data.frame with columns named X, D1, D2, D3 I know I can get a single plot with 3 curves by doing xyplot(D1 + D2 + D3 ~ X, data) but in some cases I might have columns D1 ... D10. Is there a way to plot all 10 columns without having to specify each individual term? (By analogy with formulae in lm, I thought, xyplot(. ~ X, data) would work, but it didn't) Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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] merging plot labels in a lattice plot
Hi, I have a lattice lot conditioned on two variables. Example code is: library(lattice) x <- data.frame(d=runif(100), f1=sample(c('yes', 'no'),100,replace=TRUE), f2=c(rep('Run1',30),rep('Run2',30),rep('Run3',40))) histogram(~d | f1 + f2, x) In the plot, for a given value of f2, there are two panels, one for 'n' and one for 'yes'. But above each panel I get the value of f2. What I'd like to be able to do is to have the value of f2 span the two panels (ie merge the green rows and use a single label). Any pointers as to how I could acheive this would be appreciated Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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] lattice code to plot columns over another variable
Hi, I've been struggling with a lattice visualiation. I have a data.frame with 4 columns. What I'd like to have is a set of 3 panels. Ecah panel will have the first column plotted against serial number and then will superimpose the relevant column. My non-lattice version is as follows: x <- data.frame( ... ) par(mfrow=c(3,1)) for (i in 2:4) { plot(x[,1]) points(x[,i]) } Any suggestions as to how I could convert this to a lattice version would be much appreciated Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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] lattice visualization - superpose multiple columns over another (fixed) column
Hi, I've been struggling with a lattice visualiation. I have a data.frame with 4 columns. What I'd like to have is a set of 3 panels. Ecah panel will have the first column plotted against serial number and then will superimpose the relevant column. My non-lattice version is as follows: x <- data.frame( ... ) par(mfrow=c(3,1)) for (i in 2:4) { plot(x[,1]) points(x[,i]) } Any suggestions as to how I could convert this to a lattice version would be much appreciated Thanks, -- Rajarshi Guha NIH Chemical Genomics Center __ 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] reconfiguring R to use Java 1.6 on OS X
Hi, I'm running R 2.9.0 on OS X Tiger (10.5.8). When I use rJava I see that it is using the 1.5.0 JRE. When I tried to reconfigure R to use the 1.6 JDK that I have installed, I did sudo R CMD javareconf and I get Java interpreter : /usr/bin/java Java version : 1.5.0_16 Java home path : /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home Java compiler: /usr/bin/javac Java headers gen.: /usr/bin/javah Java archive tool: /usr/bin/jar Java library path: JNI linker flags : -framework JavaVM JNI cpp flags: -I$(JAVA_HOME)/include Updating Java configuration in /Library/Frameworks/R.framework/Resources sed: -e: No such file or directory sed: s|JAVA_CPPFLAGS =.\{0,\}|JAVA_CPPFLAGS = -I$(JAVA_HOME)/include|g: No such file or directory sed: -e: No such file or directory sed: s|JAVA_CPPFLAGS =.\{0,\}|JAVA_CPPFLAGS = -I$(JAVA_HOME)/include|g: No such file or directory Done. While it is looking at /usr/bin/java, when I manually run /usr/bin/java -version I get java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode) How could I get R to use the 1.6 JDK rather than the 1.5 JDK? Thanks -- Rajarshi Guha NIH Chemical Genomics Center __ 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] problem post request with RCurl
Hi, I am trying to use a CGI service (Pubchem PUG) via RCurl and am running into a problem where the data must be supplied via POST - but I don't know the keyword for the argument. The data to be sent is an XML fragment. I can do this via the command line using curl: I save the XML string to a file called query.xml and then do curl -d @query.xml "http://pubchem.ncbi.nlm.nih.gov/pug/pug.cgi"; I get the expected response. More importantly, the verbose option shows: > Accept: */* > Content-Length: 1227 > Content-Type: application/x-www-form-urlencoded However, when I try to do this via RCurl, the data doesn't seem to get sent: q <- "InputData_query> Query_type> QueryType_qas>QueryActivitySummary> QueryActivitySummary_output value=\"summary-table\">0QueryActivitySummary_output> QueryActivitySummary_type value=\"assay-central\">0QueryActivitySummary_type> QueryActivitySummary_scids>QueryUids> QueryUids_ids>List> pccompoundList_db> List_uids>3243128ID-List_uids_E> List_uids> QueryUids> QueryActivitySummary_scids>QueryActivitySummary> PCT-QueryType>PCT-InputData_query> " > postForm(url, q, style="post", .opts = list(verbose=TRUE)) * About to connect() to pubchem.ncbi.nlm.nih.gov port 80 (#0) * Trying 130.14.29.110... * connected * Connected to pubchem.ncbi.nlm.nih.gov (130.14.29.110) port 80 (#0) > POST /pug/pug.cgi HTTP/1.1 Host: pubchem.ncbi.nlm.nih.gov Accept: */* Content-Length: 0 Content-Type: application/x-www-form-urlencoded As you can see, the data in q doesn't seem to get sent (content-length = 0). Does anybody have any suggestions as to why the call to postForm doesn't work, but the command line call does? Thanks, Rajarshi Guha| NIH Chemical Genomics Center http://www.rguha.net | http://ncgc.nih.gov Q: Why did the mathematician name his dog "Cauchy"? A: Because he left a residue at every pole. __ 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] converting a vector of bytes to a PNG/JPEG image
Hi, I have some code that uses rJava. One of the Java side methods returns a byte[] representing the bytes from a PNG image. What I'd like to do is to be able to bring up the PNG on the R side (I can bring up a Swing window to show the PNG but I want to avoid that). I have looked at the pixmap and rimage packages but don't seem to be able to work out how I'd go about this (or if it's at all possible). Does anybody have any pointers? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center [[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] using a custom color sequence for image()
Hi, I'd like to use a custom color sequence (black - low values, green - high values) in am image() plot. While I can specify colors (say a sequence of grays) to the col argument, the ordering is getting messed up. I have two questions: 1. How can I get a sequence of say 256 colors starting from black and ending in green? 2. How is this specified to image() such that it uses the colors in the proper ordering? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center [[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] decision trees using the Hellinger distance rather than
Hi, while working with decision trees and unbalanced data, I came across the use of the Hellinger distance as an alternative to information gain [1,2], when dealing with skewed data. Does anybody know of R implementations of this approach to decision trees? Thanks, [1] http://www.cse.nd.edu/Reports/2008/TR-2008-06.pdf [2] http://csmr.ca.sandia.gov/~wpk/slides/wdmda-sem.pdf -- Rajarshi Guha NIH Chemical Genomics Center [[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.
Re: [R] R and REST API's
On Mon, Sep 28, 2009 at 10:01 AM, Gary Lewis wrote: > Hi - Many organizations now make their data available as XML via a > REST web service architecture. Is there any R package or facility to > access this type of data directly (eg, to make the HTTP GET request > and have the downloaded data put into an R data frame)? > The url() function together with the XML package should let you do this -- Rajarshi Guha NIH Chemical Genomics Center [[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.
Re: [R] loading a package .Rda file at package load time
Thanks for the pointer. I should have looked at variable values first! It appears that libname contains the path to the library and then loading the rda file is just a matter of constructing the path properly On Mon, Sep 14, 2009 at 3:28 PM, cls59 wrote: > > > > Hi, I have seen the answer to this sometime before but I just can't find it > again - pointers appreciated. > > I have a package that contains some data.frames saved as .Rda files in the > data/ directory. When the package is loaded I would like to have them be > available in the workspace (without the user having to explicitly load them > using data(...)). > > If my package does not use a NAMESPACE, I can place data(varName) in > .First.lib. However if I use NAMESPACES then the above line will fail when > placed in .onLoad. I was thinking of doing something such as > load'filename.Rda') but that would require me to know the path to the > package in a platform independent way. > > Can anybody suggest how I can acheive this? > > Thanks, > > -- > Rajarshi Guha > > > You mentioned that you used something similar to: > > .First.lib <- function( libname, pkgname ){ > > data( varName ) > > } > > And it didn't work when you attached a NAMESPACE to the package. If your > .Rda files are stored in the data directory of the package, have you tried > using: > > .First.lib <- function( libname, pkgname ){ > > data( varName, package = pkgname ) > > } > > > If that doesn't work, then system.file() may be used to explicity recover > the location of your package data files: > > .First.lib <- function( libname, pkgname ){ > > data( system.file( 'data/myDataFile.Rda', package = pkgname ) > > } > > Good luck! > > -Charlie > > - > Charlie Sharpsteen > Undergraduate > Environmental Resources Engineering > Humboldt State University > -- > View this message in context: > http://www.nabble.com/loading-a-package-.Rda-file-at-package-load-time-tp25439508p25441073.html > Sent from the R help mailing list archive at Nabble.com. > > __ > 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. > -- Rajarshi Guha NIH Chemical Genomics Center [[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] loading a package .Rda file at package load time
Hi, I have seen the answer to this sometime before but I just can't find it again - pointers appreciated. I have a package that contains some data.frames saved as .Rda files in the data/ directory. When the package is loaded I would like to have them be available in the workspace (without the user having to explicitly load them using data(...)). If my package does not use a NAMESPACE, I can place data(varName) in .First.lib. However if I use NAMESPACES then the above line will fail when placed in .onLoad. I was thinking of doing something such as load'filename.Rda') but that would require me to know the path to the package in a platform independent way. Can anybody suggest how I can acheive this? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center [[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] plotting a PNG from an in-memory object
Hi, I have code which, via rJava can bring up a JFrame to display an image. What I'd like to be able to is to capture that image and make an R plot out of it (analogous to plotting a PNG file, but not from an actual file). I can rite Java code that could be called from R to take a snapshot of the window, but is it at all possible to some return that data to the R side to display via plot()? Any pointers would be appreciated -- Rajarshi Guha [[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.
Re: [R] an idiom to handle i'th element of a set of lists simultaneously
Thanks to all who replied. mapply does the trick On Tue, Jun 23, 2009 at 8:11 AM, Rajarshi Guha wrote: > Hi, I have 3 lists, x, y, z and I'd like to perform a calculation over all > the lists simultaneously. If it were a single list I could use lapply, but > for more than one list I'm using a for loop. Is there an idiom that would > let me use something like lapply, but the function specified to lappy would > have access to an element from each list? (In Python, I would have used for > a,b,c in zip(x,y,z): ...) > > Thanks, > > -- > Rajarshi Guha > -- Rajarshi Guha [[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] an idiom to handle i'th element of a set of lists simultaneously
Hi, I have 3 lists, x, y, z and I'd like to perform a calculation over all the lists simultaneously. If it were a single list I could use lapply, but for more than one list I'm using a for loop. Is there an idiom that would let me use something like lapply, but the function specified to lappy would have access to an element from each list? (In Python, I would have used for a,b,c in zip(x,y,z): ...) Thanks, -- Rajarshi Guha [[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] checking and building ROracle on OS X
Hi, I'm running R 2.9.0 (from the DMG) on OS X 10.5 and am trying to get ROracle 0.5-9 to check and build. I have installed the full Oracle installation (10.2.0.4.0). The problem I'm facing is that I need to compile ROracle.so as 32 bit, but my environment needs to point to the 64 bit Oracle libs for the compilatin process to work (since the Pro*C compiler is 64 bit and needs the 64 bit libs). So my DYLD_LIBRARY_PATH poins to the 64 bit libs, but the package should be built with the 32 bit libs Looking at the configure.in file, I see that I can specify configure arguments to indicate a 32 bit build - but I can't see how I can specify these args via R CMD CHECK or R CMD BUILD. Any pointers would be appreciated. -- Rajarshi Guha [[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.
Re: [R] vignettes are installed but not viewable?
On Feb 7, 2009, at 3:13 PM, Romain Francois wrote: Hi, Have you tried : > vignette( package = "rcdk" ) Yes, I had tried that > vignette(package='rcdk') no vignettes found --- Rajarshi Guha GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 --- A committee is a group that keeps the minutes and loses hours. -- Milton Berle __ 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] vignettes are installed but not viewable?
Hi, I have a package for which I'm writing a vignette. The vignette looks fine as indicated by R CMD check. However after installing the package (in my personal R library location) doing vignette('rcdk') says Warning message: vignette 'rcdk' *not* found But I can see the PDF file located under rcdk/doc in the R library directory. The header of the Rnw file is % \VignetteIndexEntry{rcdk Tutorial} % \VignettePackage{rcdk} % \VignetteKeywords{} I am totally stumped by this - could anybody shed some light on what I'm doing wrong? Thanks, --- Rajarshi Guha GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 --- Does Ramanujan know Polish? -- E.B. Ross __ 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.
Re: [R] rgl lighting question
Thanks a lot for the pointer to rgl.pop() - that works (as does looking at the examples!) On Nov 22, 2008, at 10:28 AM, Duncan Murdoch wrote: On 21/11/2008 2:30 PM, Rajarshi Guha wrote: Hi, I'm using rgl to generate a 3D surface plot and I'm struggling to get the lighting correct. Currently the surface gets plotted, but is very 'shiny'. On rotating the view, I get to see parts of the surface - but overall I don't see much detail because of the spotlight like lighting. I've played around with the specular, ambient and diffuse but I can't bring out the details of the surface. Could anybody point me to some examples of how to make a plain matte surface, which isn't obscured by specular reflections? This gives the regular shiny surface: library(rgl) example(surface3d) This gives one with no specular reflections, because the material doesn't do that: open3d() surface3d(x, y, z, color=col, back="lines", specular="black") And here's another way to get no specular reflections. This time there's no light to reflect that way: open3d() rgl.pop("lights") light3d(specular="black") surface3d(x, y, z, color=col, back="lines") I suspect you missed the rgl.pop() call. If you just call light3d or rgl.light() you'll add an additional light, you don't change the existing one. Duncan Murdoch --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 --- Paper or plastic? Not 'Not paper AND not plastic!!' -- Augustus DeMorgan in a grocery store __ 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] rgl lighting question
Hi, I'm using rgl to generate a 3D surface plot and I'm struggling to get the lighting correct. Currently the surface gets plotted, but is very 'shiny'. On rotating the view, I get to see parts of the surface - but overall I don't see much detail because of the spotlight like lighting. I've played around with the specular, ambient and diffuse but I can't bring out the details of the surface. Could anybody point me to some examples of how to make a plain matte surface, which isn't obscured by specular reflections? Thanks, --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 --- If you don't get a good night kiss, you get Kafka dreams." -Hobbes __ 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] using an image as a dendrogram label
Hi, does anybody know if it is possible to use an image (rather than text) to label the leaves of a dendrogram? I realize that this will not always lead to a useful on-screen display, but ideally I'd like to directly go from the dendrogram to a PDF and on-screen viewing is not to too important for me. Also, my trees are relatively small. Any pointers would be apreciated --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 --- A man is known by the company he organizes. -- Ambrose Bierce __ 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] 'distance' between a vector and a permutation of the vector
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I've been trying to identify a good way to do the following: Say I have a vector of unique, integers x <- c(1,3,2,4,5) I then have a permuted version of the above vector, say y <- c(1,3,5,2,4) Is there an easy way to get the "distance" between the two vectors. The sense I'm thinking of is such, that if we have y <- c(1,3,2,5,4) then this is 'closer' to x, since there is only one pair that is mis- ordered, compared to something like y <- c(1,5,3,4,2) It seems that a good candidate would be the levenstein distance - is there a function that would work on vectors of integers rather than strings? Are there more suitable candidates? Thanks for any pointers - --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84 - --- Q: What's polite and works for the phone company? A: A deferential operator. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkfe/eUACgkQZqGSLFHnnoSyVwCfVi8eLnXy1eCYfAwOEF2F93cJ 1BUAoPD9vTagEGNKom5hCuR8ppb0bVgZ =hbc7 -END PGP SIGNATURE- __ 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] snow on OS X
Hi, I installed snow via R.app (from R 2.6.0) on OS X (10.4.11, Tiger), though I did not install Rmpi or Rsprng. My first question - has anybody installed Rsprng on OS X? The link from the CRAN package page seems to indicate that the sprng code was not installed rather than Rsprng not building. Second, I tried to create a cluster using the SOCKET option by doing cl <- makeSOCKcluster(rep('localhost',2)) However, after issuing this, R just seems to hang. I have set up passwordless ssh, so that doing ssh localhost logs me into my machine without any password, so I'm not sure what the problem is Any pointers would be appreciated --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- ...but there was no one in it... - RG __ 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.
Re: [R] Analyzing Publications from Pubmed via XML
On Dec 13, 2007, at 9:16 PM, Farrel Buchinsky wrote: > I am afraid not! The only thing I know about Python (or Perl, Ruby > etc) is that they exist and that I have been able to download some > amazing freeware or open source software thanks to their existence. > The XML package and specifically the xmlTreeParse function looks as > if it is begging to do the task for me. Is that not true? Certainly - probably as a better Python programmer than an R programmer, it's faster and neater for me to do it in Python: from elementtree.ElementTree import XML import urllib url = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/erss.cgi? rss_guid=0_JYbpsax0ZAAPnOd7nFAX-29fXDpTk5t8M4hx9ytT-' con = urllib.urlopen(url) dat = con.read() root = XML(dat) items = root.findall("channel/item") for item in items: category = item.find("category") print category.text The problem is that the RSS feed you linked to, does not contain the year of the article in an easily accessible XML element. Rather you have to process the HTML content of the description element - which, is something R could do, but you'd be using the wrong tool for the job. In general, if you're planning to analyze article data from Pubmed I'd suggest going through the Entrez CGI's (ESearch and EFetch) which will give you all the details of the articles in an XML format which can then be easily parsed in your language of choice. This is something that can be done in R (the rpubchem package contains functions to process XML files from Pubchem, which might provide some pointers) --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- Writing software is more fun than working. __ 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.
Re: [R] Analyzing Publications from Pubmed via XML
On Dec 13, 2007, at 9:03 PM, Farrel Buchinsky wrote: > I would like to track in which journals articles about a particular > disease > are being published. Creating a pubmed search is trivial. The search > provides data but obviously not as an R dataframe. I can get the > search to > export the data as an xml feed and the xml package seems to be able > to read > it. > > xmlTreeParse(" > http://eutils.ncbi.nlm.nih.gov/entrez/eutils/erss.cgi? > rss_guid=0_JYbpsax0ZAAPnOd7nFAX-29fXDpTk5t8M4hx9ytT- > ",isURL=TRUE) > > But getting from there to a dataframe in which one column would be > the name > of the journal and another column would be the year (to keep things > simple) > seems to be beyond my capabilities. If you're comfortable with Python (or Perl, Ruby etc), it'd be easier to just extract the required stuff from the raw feed - using ElementTree in Python makes this a trivial task Once you have the raw data you can read it into R --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- A committee is a group that keeps the minutes and loses hours. -- Milton Berle __ 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] adding an image to a plot
Hi, I'm writing code to generate a plot, in which I draw a series of rectangles. So my code is of the form plot.new() plot.window( ... ) draw rectangle draw rectangle ... Is there a way for me to insert a PNG or PDF graphic at a specific position in the plot (ideally in plot coordinates)? I realize that this might probably be better done in a separate image editor, but if it could be done programmatically that would be very handy Thanks, --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- So the Zen master asked the hot-dog vendor, "Can you make me one with everything?" - TauZero on Slashdot __ 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.
Re: [R] Someone Using Java/R Interface--- JRI ?
We use JRI as par of a R web service infrastructure, where we have Java classes around specific R functions (lm, randomForest, nnet etc) as well as classes that call arbitrary R code You can look at the code at http://cicc-grid.svn.sourceforge.net/ viewvc/cicc-grid/cicc-grid/rws/trunk/src/net/sf/ciccgrid/frontend/ On Sep 12, 2007, at 10:50 PM, Vaibhav Gathibandhe wrote: > Hi all, > > I am writing R code and I want to interface with JAVA i.e. I want > to call R > from JAVA. That's why i have installed JRI on my machine. > > There is also documentation available in "Javadoc". > > But as i am very new to JAVA and well as R, I don't understand > much of it. > > If someone is using this package i.e. JRI, please let me know > whether i am > going in right direction or not. > > As i am using regressions, Boot library etc. in my R codes. Is it > possible > to use all these if i use JRI package? > > [[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. --- Rajarshi Guha <[EMAIL PROTECTED]> GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE --- In matrimony, to hesitate is sometimes to be saved. -- Butler __ 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.