Re: [R] side-effects in functions that replace object values andattributes

2010-02-17 Thread Stephen Tucker
wdun...@tibco.com To: Stephen Tucker brown_...@yahoo.com; r-help@r-project.org Sent: Tue, February 16, 2010 5:50:38 PM Subject: RE: [R] side-effects in functions that replace object values andattributes -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r

[R] side-effects in functions that replace object values and attributes

2010-02-16 Thread Stephen Tucker
Hello list, I encountered some surprising behavior in R and wanted to check to see if I was imagining things. Previously, I thought that replacement/setter operators in prefix notation (e.g., `[-`(x,1,y) rather than x[1] - y) did not produce side effects (i.e., left 'x' unchanged), but just

[R] Compose in roxygen - order of function application?

2010-02-10 Thread Stephen Tucker
Hello, I wonder if anyone has used the Compose() function in the 'roxygen' package. I find its behavior a bit surprising: f - function(x) x + 1 g - function(x) x * 2 f(g(2)) [1] 5 Compose(f,g)(2) [1] 6 g(f(2)) [1] 6 Compose(g,f)(2) [1] 5 I would have expected Compose(f,g)(x) == f(g(x))

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Stephen Tucker
You may want to use the reshape package for this task: library(reshape) recast(DF3,Show ~ Datetime, id.var=names(DF3),value=Measure) Show 08/26/2009 11:30 AM 08/26/2009 9:30 AM 1 Firefly 3 1 2 Red Dwarf 4 2 If you

Re: [R] Merge data frames but with a twist.

2009-08-27 Thread Stephen Tucker
To: Stephen Tucker brown_...@yahoo.com Cc: Tony Breyal tony.bre...@googlemail.com; r-help@r-project.org Sent: Thursday, August 27, 2009 7:27:26 AM Subject: Re: [R] Merge data frames but with a twist. On Thu, Aug 27, 2009 at 9:55 AM, Stephen Tuckerbrown_...@yahoo.com wrote: You may want to use the reshape

Re: [R] concatenating multiple columns from files

2009-07-31 Thread Stephen Tucker
You can do something like mat - do.call(cbind, lapply(list.files(.data),read.table)) ## explanation: lapply(list.files(.data),read.table) will store all tables in a list do.call(cbind,...) will bind all the columns stored in the list created above. - Original Message From:

Re: [R] PDF Compression

2009-07-30 Thread Stephen Tucker
There was a previous post about this also: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html I was able to use bitmap(,type=pdfwrite) on Ubuntu Linux but had trouble getting it to work on Windows. For now, it's kind of kludgey but I have in my .Rprofle (or .Rprofile.site on Windows):

[R] R_LIBS in Windows Vista

2009-04-01 Thread Stephen Tucker
Hello, I am trying to install R and have it running through ESS on a Vista machine that is not mine (I am only familiar with Windows XP and Ubuntu Linux) so please pardon my unfamiliarity... The Rgui.exe installation works fine and package installation also appears to work fine. The base

[R] behavior of squishplot in TeachingDemos

2009-03-03 Thread Stephen Tucker
Hi list, I wonder if anyone has had this experience with squishplot() in the TeachingDemos package. Taking the example from the ?image help page, library(TeachingDemos) x - 10*(1:nrow(volcano)) y - 10*(1:ncol(volcano)) layout(matrix(c(1,2,3,4),ncol=2,byrow=TRUE),height=c(2,1)) ## 1st plot op

[R] importing data to SQLite database with sqldf

2009-02-19 Thread Stephen Tucker
.txt file from Python's SQLite interface, I get .db files that are approximately the same size as the .txt file (~500KB). Is the larger file size for sqldf's method expected? Many thanks in advance! Stephen Tucker __ R-help@r-project.org mailing list

[R] plot order in multi-panel figure

2008-09-19 Thread Stephen Tucker
Hi, Does anyone know if there is a way to 'reset the plot number' on a traditional graphics device? For instance, I want to have two plots on stacked top of each other (mfrow=c(2,1)) but with underlying grid lines spanning both figures vertically. I can put the grid lines on top if I add

Re: [R] Pdf file size for very scatter plots

2008-08-15 Thread Stephen Tucker
I thought running it through latex will compress the pdf - but this post nicely summarizes some options: http://tolstoy.newcastle.edu.au/R/e2/help/07/05/17475.html I personally prefer the pdftk approach* over the ghostscript option** as the latter seems to give me a number of problems on

Re: [R] tryCatch question

2008-08-14 Thread Stephen Tucker
Hi Kevin, I learned to use tryCatch() from this page: http://www1.maths.lth.se/help/R/ExceptionHandlingInR/ Hope this helps, ST - Original Message From: Luke Tierney [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: r-help@r-project.org Sent: Thursday, August 14, 2008 8:59:35 AM Subject:

Re: [R] levels values of cut()

2008-08-09 Thread Stephen Tucker
Not sure what you're looking for, but does this help? Extending your code, library(gsubfn) t(strapply(levels(my.cuts),([0-9.]+),([0-9.]+), + function(...) as.numeric(c(...)),backref=-2,simplify=TRUE)) [,1] [,2] [1,] 15.9 38.3 [2,] 38.3 60.7 [3,] 60.7 83.1 - Original

Re: [R] Extract Element of String with R's Regex

2008-08-01 Thread Stephen Tucker
In the example below, a straight application of strsplit() is probably the simplest solution. In a more general case where it may be desirable to match patterns, a combination of sub() or gsub() with strsplit() might do the trick: x - Best-K Gene 11340 211952_at RANBP5 Noc= 3 - 2 LL= -963.669

[R] chron objects: input/output

2008-08-01 Thread Stephen Tucker
Hi list, I have some questions regarding 1) conversion of date + time characters to chron 2) formatting chron object printing Regarding (1), Gabor's Rnews 2004 4/1 article has been indispensible, but I often work with files where dates and times are contained in a single field. In this case, I

Re: [R] Colors in Sweave

2008-08-01 Thread Stephen Tucker
From: Duncan Murdoch murdoch_at_stats.uwo.ca Date: Tue, 29 Jul 2008 19:45:28 -0400 On 27/07/2008 3:10 PM, Stephen Tucker wrote: Hi list, I was using Sweave and was wondering if anyone has had any luck changing the font colors of the code chunks. For instance, in my .Rnw preample I tried

Re: [R] Storing Matrices into Hash

2008-07-31 Thread Stephen Tucker
Hm didn't know about the abind package. That is pretty sweet. I do often opt for the 'list of matrices' myself though because I'm more familiar with the methods for lists... To answer one of Gundala's questions directly (assuming list of matrices is acceptable): Since you can do this, x -

[R] Colors in Sweave

2008-07-27 Thread Stephen Tucker
Hi list, I was using Sweave and was wondering if anyone has had any luck changing the font colors of the code chunks. For instance, in my .Rnw preample I tried including: === \usepackage[usenames]{colors} \definecolor{darkred}{rgb}{0.545,0,0} \definecolor{midnightblue}{rgb}{0.098,0.098,0.439}

Re: [R] Object-oriented programming in R for Java programmers?

2008-07-27 Thread Stephen Tucker
I've never used it myself but I recall reading about this R.oo package a while ago - might be worth considering? http://www1.maths.lth.se/help/R/R.oo/ - Original Message From: Werner Wernersen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, July 27, 2008 4:55:26 AM Subject: [R]

Re: [R] Object-oriented programming in R for Java programmers?

2008-07-27 Thread Stephen Tucker
This page is also a brief introduction to the S3 classes: http://www.ibm.com/developerworks/linux/library/l-r3.html (see section on 'Object-oriented R') and for S4, in addition to How S4 methods work: http://developer.r-project.org/methodDefinition.html - Original Message From:

Re: [R] help with data layout

2008-07-17 Thread Stephen Tucker
Hi, hope this will help: txt - Col1,Col2 A,3 , 2 ,3 B,4 , 5 , 4 C,1 , 4 , 3 ## read data dat - read.csv(textConnection(txt),na.string=) ## fill in empty cells with correct category dat$Col1[] - Reduce(function(x,y)

Re: [R] Plot Mixtures of Synthetically Generated Gamma Distributions

2008-07-07 Thread Stephen Tucker
Are you trying to look at the difference in the gamma distributions due to variations in the shape and scale parameters? In this case, the following approach might be more straightforward: ## assign parameter values params - list(curve1=c(1,1),curve2=c(1,2),curve3=c(1,3)) ## define function

Re: [R] Method for checking automatically which distribtions fits a data

2008-07-07 Thread Stephen Tucker
I don't know that there is a single function, but you can perhaps apply a sequence of available functions - For instance, you can use fitdistr() in library(MASS) to estimate optimal parameters for a candidate set of distributions; then look at each fit and also compare the deviance among the

Re: [R] operations on all pairs of columns from two matrices

2008-06-18 Thread Stephen Tucker
how about this? m1 - matrix(rep(1:3,each=5),ncol=3) m2 - matrix(1:15,ncol=3) array(apply(m1,2,function(x,m) m-x,m2),dim=c(dim(m2),ncol(m1))) - Original Message From: Daren Tan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 18, 2008 7:36:45 AM Subject: [R] operations on

Re: [R] try catch block

2008-06-17 Thread Stephen Tucker
This is a useful reference on the tryCatch() function: http://www1.maths.lth.se/help/R/ExceptionHandlingInR/ I think something like this should work: xml - tryCatch(xmlTreeParse(xmlTxt, useInternal=TRUE), error=function(err) xmlMalFormed()) - Original Message From: ppatel3026

[R] adding custom axis to image.plot() and strange clipping behavior

2008-06-13 Thread Stephen Tucker
Hi list, I wanted to plot an image with a colorbar to the right of the plot, but set my own axis labels (text rather than numbers) to the image. I have previously accomplished this with two calls to image(), but the package 'fields' has a wrapper function, image.plot(), which does this task

Re: [R] Data manipulation

2007-10-15 Thread Stephen Tucker
Hi Klaus, I am not exactly sure what you are asking for, but something like this? This would be option (2) from your list - I don't know that it would be too difficult in R that you would want to use another tool. filt - function(x) with(x,which(Hole 1)) normalize - function(x,y) {

Re: [R] vector name

2007-09-17 Thread Stephen Tucker
Hi, Either of the following should work (I assume there are 28 elements in your list): fdata - cbind(as.matrix(as.data.frame(filtered)), myregime) fdata - cbind(colnames-(matrix(unlist(filtered),ncol=28), names(filtered)), myregime) --- livia [EMAIL PROTECTED] wrote: I have got a