From istazahn at gmail.com  Mon Feb  3 17:29:32 2014
From: istazahn at gmail.com (Ista Zahn)
Date: Mon, 3 Feb 2014 11:29:32 -0500
Subject: [Rd] seq range argument
In-Reply-To: <CALxY2LdGEGcFPo4jxEr_XnMLp4zWio=nbmMuPPUCo-oKkCdcaA@mail.gmail.com>
References: <DUB123-W38EA0ACC05B6A132C636B0D5AB0@phx.gbl>
	<CALxY2LdGEGcFPo4jxEr_XnMLp4zWio=nbmMuPPUCo-oKkCdcaA@mail.gmail.com>
Message-ID: <CA+vqiLF_vP+s7nh=Xt89P9ae2QQk+FKtqxuR=2ppGPqr6Cy-SA@mail.gmail.com>

This is slightly more verbose, but perhaps

do.call("seq", as.list(c(extendrange(D_orig, f=0.1), len=100)))

Best,
Ista

On Mon, Feb 3, 2014 at 9:00 AM, Lorenz, David <lorenz at usgs.gov> wrote:
> Berry,
>   It sounds like you just need a little helper function like this:
>
> ser <- function(x, len=100, f=0.1) {
>    dr <- extendrange(x, f=f)
>    return(seq(dr[1L], dr[2L], length.out=len))
>  }
>
> I called it ser, short for sequence extended range. Use it thusly:
>
> Ijustneed <- ser(D_orig)
>
>   Hope this helps. I use and create little help functions like this all the
> time. Even extendrange could be considered a helper function as it is only
> a couple of lines long.
> Dave
>
>
>
> On Mon, Feb 3, 2014 at 6:43 AM, Berry Boessenkool <
> berryboessenkool at hotmail.com> wrote:
>
>> Hello dear developers,
>>
>> I find myself often having the result of "range" oder "extendrange", which
>> I want to create a sequence with.
>> But "seq" needs two seperate arguments "from" and "two".
>> Could an argument "range" be added?
>>
>> Otherwise I will have to create an object with the range (may come from a
>> longer calculation), index twice from it and remove it again - kind of an
>> unnecessary bunch of code, I think.
>>
>> Here's an example:
>>
>> # What I currently do:
>> D_orig <- rnorm(20, sd=30)
>> D_range <- extendrange(D_orig, f=0.1)
>> Ijustneed <- seq(D_range[1], D_range[2], len=100)
>> rm(D_range)
>>
>> # what I'd like to have instead:
>> D_orig <- rnorm(20, sd=30)
>> Ijustneed <- seq(range=extendrange(D_orig, f=0.1), len=100)
>>
>> regards,
>> Berry
>>
>> -------------------------------------
>> Berry Boessenkool
>> Potsdam, Germany
>> -------------------------------------
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] seq range argument
Ista Zahn