Re: [R] Seeking a more efficient way to find partition maxima

2008-01-07 Thread Talbot Katz
myseq + M * cumsum(replace(0 * myseq, part, 1)) > > # calcuate on transformed version > tmp <- partiCmax(myseq2, part) > > # untransform > tmp - M * seq_along(tmp) # c(4, 6, 7) > > Also you might check how it compares to the simpler > > tapply(myseq, cumsum(replace(

Re: [R] Efficient way to substract all entries in two vectors from each other

2008-01-07 Thread Talbot Katz
Hi Joh. To echo Bert, more detail would be helpful. But here is a stab at something. Given two numeric vectors, a and b, for each entry of a this finds the index in b of the closest match. It's not efficient at all. > bestmati <- function( a, b ) { return( sapply( a, function( x ) { which.m

Re: [R] Seeking a more efficient way to find partition maxima

2008-01-07 Thread Talbot Katz
m > Date: Mon, 7 Jan 2008 10:44:20 -0600 > From: [EMAIL PROTECTED] > To: [EMAIL PROTECTED] > CC: [EMAIL PROTECTED] > Subject: Re: [R] Seeking a more efficient way to find partition maxima > > Talbot Katz wrote: >> Hi. >> >> Suppose I have a vector that I partiti

[R] Seeking a more efficient way to find partition maxima

2008-01-07 Thread Talbot Katz
Hi. Suppose I have a vector that I partition into disjoint, contiguous subvectors. For example, let v = c(1,4,2,6,7,5), partition it into three subvectors, v1 = v[1:3], v2 = v[4], v3 = v[5:6]. I want to find the maximum element of each subvector. In this example, max(v1) is 4, max(v2) is 6

[R] Seeking a more efficient way to read in a file

2008-01-02 Thread Talbot Katz
Hi. I have a matrix stored in a large, tab-delimited flat file. The first row contains column names. Because the matrix is symmetric, the file has lower triangular format, so the second row contains one number, the third row two numbers, etc. In general, row k+1 contains k numbers; the mat

Re: [R] Can you recover default argument values of a function?

2007-12-26 Thread Talbot Katz
;- function(x = u+v+w, u) { v <- u+1; x } > > in which case you would get an object of class > "name" in the first case or "call" in the second. > > > On Dec 26, 2007 4:42 PM, Talbot Katz wrote: >> >> Hi. >> >> Maybe this is a stupid

[R] Can you recover default argument values of a function?

2007-12-26 Thread Talbot Katz
Hi. Maybe this is a stupid question. If so, I apologize, but here goes. Suppose I have a function f1(x,...) that calls a function f2(y1,y2,...,yn) in the following way: if x satisfies a certain condition, then I want to call f2(x,y2,...,yn); otherwise I want to use the default value of y1,

Re: [R] Quote: An embedded and charset-unspecified text was scrubbed...

2007-12-20 Thread Talbot Katz
Duncan, thank you for the suggestion. This should be a plain text message, perhaps it will post correctly to the R-help Archives. -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/

Re: [R] Quote: An embedded and charset-unspecified text was scrubbed...

2007-12-20 Thread Talbot Katz
An embedded and charset-unspecified text was scrubbed...> > On 20/12/2007 3:43 PM, Talbot Katz wrote:> > Occasionally when I click on a posting in the archives, I don't see the actual message, but instead, something like the following:> > > > An embedded and charset-u

[R] Quote: An embedded and charset-unspecified text was scrubbed...

2007-12-20 Thread Talbot Katz
Occasionally when I click on a posting in the archives, I don't see the actual message, but instead, something like the following: An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/200712XX/aXXX/attachment.pl

[R] Function reference

2007-12-19 Thread Talbot Katz
Hi. I'm looking for an R equivalent to something like function pointers in C/C++. I have a search procedure that evaluates the fitness of each point it reaches as it moves along, and decides where to move next based on its fitness evaluation. I want to be able to pass different fitness func

Re: [R] Reading through a group of .RData files

2007-12-11 Thread Talbot Katz
t; > myObj > <- load(file.path(fnDir, cvListFiles[i]))> myFunction(get(myObj))> > rm(list=myObj)> > might be closer to what you want.> > moreover, if > length(myObj) > 1, you might want sth like:> > lapply(myObj, function(x) > myFunction(get(x)))>

[R] Reading through a group of .RData files

2007-12-10 Thread Talbot Katz
Hi. I have a procedure that reads a directory, loops through a set of particular .RData files, loading each one, and feeding its object(s) into a function, as follows: cvListFiles<-list.files(fnDir); for(i in grep(paste("^",pfnStub,".*\\.RData$",sep=""),cvListFiles)){ load(paste(fnDir,cvList

Re: [R] RMySQL LoadLibrary failure: Invalid access to memory location.

2007-10-19 Thread Talbot Katz
Hi. A colleague of mine figured out how to get the RMySQL 0.6 package to load properly in our environment with MySQL 5.0.45. Every time I tried to load the RMySQL library in R 2.5.1 I was getting an error message: LoadLibrary failure: Invalid access to memory location. We did the following:

[R] RMySQL LoadLibrary failure: Invalid access to memory location.

2007-10-16 Thread Talbot Katz
Hi. I'm sorry to revisit a problem that's been much discussed, but I haven't yet been able to overcome it. I am running R 2.5.1 on Windows XP Professional 5.1 (Service Pack 2), and I believe I have MySQL 5.0.45 installed (I downloaded and installed mysql-essential-5.0.45-win32.msi from http:/

[R] Is it solve.QP or is it me?

2007-09-21 Thread Talbot Katz
Hi. Here are three successive examples of simple quadratic programming problems with the same structure. Each problem has 2*N variables, and should have a solution of the form (1/N,0,1/N,0,...,1/N,0). In these cases, N=4,5,6. As you will see, the N=4 and 6 cases give the expected solution, b

Re: [R] "Save to File..." option on File menu

2007-09-13 Thread Talbot Katz
Thank you for bringing your thread to my attention. The discussion therein pretty much encapsulated what I was trying to find out. -- TMK -- 212-460-5430home 917-656-5351cell >From: "Muenchen, Robert A (Bob)" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]>

[R] "Save to File..." option on File menu

2007-09-12 Thread Talbot Katz
Hi. There was an interesting thread about a year ago, called 'Command equivalent of rgui "File, Save to File"?' (http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0553.html) started by Michael Prager, and contributed to by Duncan Murdoch (I didn't notice anything beyond the four entries they po