Re: [R] collapse a list of dataframes

2015-02-02 Thread dan wang
How about this, t <- lapply(a,function(x){colnames(x)=c("A","B");return(x)}) do.call(rbind,t) On Mon, Feb 2, 2015 at 4:00 PM, Tom Wright wrote: > Hi all, > > I'm trying to avoid loops (no real reason, just as an exercise). > > Given a list: > > list(data.frame(a=1:3,b=letters[1:3]),data.frame(x

Re: [R] Best way to get the prices from these strings?

2014-01-29 Thread dan wang
I am not sure if below ways are better. sub(".*>(.*)<.*","\\1",thePrices) sapply(thePrices, function(x){s=gregexpr(pattern ='\\$',x)[[1]][1];e=gregexpr(pattern ='<',x)[[1]][1];return(substr(x,s,e-1))}) On Wed, Jan 29, 2014 at 9:29 AM, Keith S Weintraub wrote: > Folks, > > I got the following

Re: [R] integrate

2013-11-21 Thread dan wang
That works. Thanks a lot! On Wed, Nov 20, 2013 at 11:52 PM, David Winsemius wrote: > > On Nov 20, 2013, at 8:39 PM, David Winsemius wrote: > > > > > On Nov 20, 2013, at 7:12 PM, dan wang wrote: > > > >> Hi all, > >> > >> Can anyone help me

[R] about the integrate

2013-11-21 Thread dan wang
Hi all, I tried below two methods to calculate the integrate of a same function. Two different results are given. The first one should be the right answer. Can any one help to explain why? Another issue is, the first one is not convenient as I have to update the mu and sigma outside the function.

[R] integrate

2013-11-20 Thread dan wang
Hi all, Can anyone help me with below integrate function? Basically, I want to calculate the integral of the sum of two kernel density functions. But the error shows that: In x - a : longer object length is not a multiple of shorter object length y1 = rnorm(10) y2 = rnorm(10) fhat <- functio

Re: [R] modify functions in "stats", but .Call(C_BinDist, ...) couldn't load C function

2013-11-15 Thread dan wang
Thanks, that works!! On Fri, Nov 15, 2013 at 11:16 AM, Prof Brian Ripley wrote: > On 15/11/2013 16:11, dan wang wrote: > >> Thanks, I think you are right.. >> How can I access this object? >> > > fortunes::fortune(14) applies. > > >> Thanks, >>

Re: [R] modify functions in "stats", but .Call(C_BinDist, ...) couldn't load C function

2013-11-15 Thread dan wang
arradas > > Em 15-11-2013 14:34, dan wang escreveu: > >> Hi all, >> >> I am trying to write a new function based on an existing function in >> "stats". >> >> This function requires to call a c program "C_BinDist". The new function >>

[R] modify functions in "stats", but .Call(C_BinDist, ...) couldn't load C function

2013-11-15 Thread dan wang
Hi all, I am trying to write a new function based on an existing function in "stats". This function requires to call a c program "C_BinDist". The new function couldn't work without load this c script. How can I find this "C_BinDist" function and load it to make my new function work through? Tha

Re: [R] integrate function

2013-02-12 Thread dan wang
pmax instead of min or max. > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -Original Message- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf > > Of dan wang > > Sent: Tuesday, February 12,