search for: ummel

Displaying 8 results from an estimated 8 matches for "ummel".

Did you mean: hummel
2011 Jan 05
4
Match numeric vector against rows in a matrix?
Two posts in one day is not a good day...and this question seems like it should have an obvious answer: I have a matrix where rows are unique combinations of 1's and 0's: > combs=as.matrix(expand.grid(c(0,1),c(0,1))) > combs Var1 Var2 [1,] 0 0 [2,] 1 0 [3,] 0 1 [4,] 1 1 I want a single function that will give the row index containing an exact match
2009 Dec 12
1
Create sequence given start and end vector
...llowing without the 'for' loop? start=c(1,10,20) end=c(4,15,27) out=c() for (i in 1:length(start)) { out=c(out,start[i]:end[i]) } out [1] 1 2 3 4 10 11 12 13 14 15 20 21 22 23 24 25 26 27 I know there must be an easier (and, hopefully, faster) way. Many thanks in advance, Kevin Ummel Central European University Department of Environmental Science and Policy
2011 Jan 05
3
How to 'explode' a matrix
Hi everyone, I'm looking for a way to 'explode' a matrix like this: > matrix(1:4,2,2) [,1] [,2] [1,] 1 3 [2,] 2 4 into a matrix like this: > matrix(c(1,1,2,2,1,1,2,2,3,3,4,4,3,3,4,4),4,4) [,1] [,2] [,3] [,4] [1,] 1 1 3 3 [2,] 1 1 3 3 [3,] 2 2 4 4 [4,] 2 2 4 4 My current kludge is this:
2010 Nov 16
2
Pass character vector to function argument
A bit embarrassed to post this seemingly trivial question, but I can't find anything in the archive that's quite relevant: a1=1 a2=2 obs=objects(pattern=glob2rx("a?")) I want to utilize 'obs' as a function argument to produce something like: sum(a1,a2) Obviously, sum(obs) doesn't work, but I've tried variations of 'eval', 'parse',
2011 Apr 14
3
Find number of elements less than some number: Elegant/fast solution needed
Take vector x and a subset y: x=1:10 y=c(4,5,7,9) For each value in 'x', I want to know how many elements in 'y' are less than 'x'. An example would be: sapply(x,FUN=function(i) {length(which(y<i))}) [1] 0 0 0 0 1 2 2 3 3 4 But this solution is far too slow when x and y have lengths in the millions. I'm certain an elegant (and computationally efficient)
2012 Jan 28
2
Need very fast application of 'diff' - ideas?
Hi everyone, Speed is the key here. I need to find the difference between a vector and its one-period lag (i.e. the difference between each value and the subsequent one in the vector). Let's say the vector contains 10 million random integers between 0 and 1,000. The solution vector will have 9,999,999 values, since their is no lag for the 1st observation. In R we have: #Set up input vector
2010 Feb 05
0
Plot point text labels over polygon w/o overlap?
...ls for points to avoid overlap of text. But is there a way to avoid/minimize overlap of text labels with the outline of an underlying polygon? For example, when plotting location of cities, one would like the text labels to not fall on top of nearby country/state borders, etc. Many thanks, Kevin Ummel Central European University Department of Environmental Science and Policy
2011 Dec 12
1
Lagged values problem requiring short solution time
...ile (any(abs(chg)>delta)) { temp = sign(chg)*chg - delta temp1=temp temp1[chg>=(-delta)] = 0 temp1 = c(temp1[length(temp1)],temp1[-length(temp1)]) temp2 = temp temp2[chg<=delta] = 0 y = y+temp1+temp2 chg = diff(c(y,y[1])) } #Solution vector: y Thank you, Kevin Kevin Ummel CARMA Project Manager Center for Global Development [[alternative HTML version deleted]]