[R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
Then I'd like to be able to quickly retrieve the value of key 1.5 to get -0.53. How would one go about doing this? Yours, Alan Lue __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] Data Frame as Hash Table

2010-05-30 Thread Alan Lue
might want to investigate the 'data.table' package. On 30/05/2010 09:03, Alan Lue wrote:  I'm interested in using a data frame as if it were a hash table.  For  instance if I had the following,  (d- data.frame(key=seq(0.5, 3, 0.5), value=rnorm(6)))      key        value  1 0.5

Re: [R] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-30 Thread Alan Lue
Is there a performance advantage to doing this, as opposed to growing the vector within the loop? I suppose R could have to dynamically reallocate memory at some point? Alan 2010/5/30 Uwe Ligges lig...@statistik.tu-dortmund.de: On 26.05.2010 08:52, Alan Lue wrote: Come to think of it, we

[R] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-26 Thread Alan Lue
Since `for' loops are slow in R, and since `apply' functions are faster, I was wondering whether there were a way to use an apply function—or to otherwise avoid using a loop—when iterating over a statement that updates its input. For example, here's some such code: r.seq - 2 * (1 / d$Dt[1] - 1)

Re: [R] Avoiding Loops When Iterating Over Statement That Updates Its Input

2010-05-26 Thread Alan Lue
Come to think of it, we can't save the output of each invocation and concatenate it later, since we need the output as input for the next iteration. Alan On Tue, May 25, 2010 at 11:43 PM, Alan Lue alan@gmail.com wrote: Since `for' loops are slow in R, and since `apply' functions

Re: [R] Counting indexes

2010-05-26 Thread Alan Lue
-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Alan Lue Master of Financial Engineering UCLA Anderson School of Management __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] Determining Index of Last Element in Vector

2010-04-25 Thread Alan Lue
achieve this using two lines, but I'm writing because I want to do it using one.) Alan -- Alan Lue Master of Financial Engineering UCLA Anderson School of Management [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https

Re: [R] Determining Index of Last Element in Vector

2010-04-25 Thread Alan Lue
Sorry -- I meant `v(end)' and `v[length(v)]' in the first examples of my message. Alan On Sun, Apr 25, 2010 at 11:10 AM, Alan Lue alan@gmail.com wrote: Hi, Is there a way to specify the last element of a vector, similar to end in MATLAB?   v[end] would be MATLAB for   v(length(v

Re: [R] Determining Index of Last Element in Vector

2010-04-25 Thread Alan Lue
Those are great solutions. Thanks so much for your help. Yours, Alan On Sun, Apr 25, 2010 at 11:43 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 25, 2010, at 2:22 PM, Chuck Cleland wrote: On 4/25/2010 2:10 PM, Alan Lue wrote: Hi, Is there a way to specify the last element

[R] Math Expression in 3D Plots

2008-11-20 Thread Alan Lue
Is there anyway to label axes in 3D plots with mathematical expressions? In the code below, I want to replace delta_yrsed with what \Delta \widehat{yrsed} represents in TeX, but the [xyz]lab parameters of title3d appear to only accept character strings. require(rgl) fn.delta.yrsed -

[R] Updating Packages with Personal Library

2008-11-07 Thread Alan Lue
I'm having trouble running `updates.packages()' and installing into a personal library. Setup: 1. .Renviron file contains: R_LIBS_USER=~/lib/R/%p-library/%v 2. Hence personal library is: ~/lib/R/i486-pc-linux-gnu-library/2.6/ 3. Library path upon starting R: .libPaths() [1]

Re: [R] Updating Packages with Personal Library

2008-11-07 Thread Alan Lue
Test. On Fri, Nov 7, 2008 at 2:40 AM, Alan Lue [EMAIL PROTECTED] wrote: I'm having trouble running `updates.packages()' and installing into a personal library. Setup: 1. .Renviron file contains: R_LIBS_USER=~/lib/R/%p-library/%v 2. Hence personal library is: ~/lib/R/i486-pc-linux-gnu