[R] quantmod getOptionChain Interpret List Label As Date

2018-03-04 Thread John Sparks
Hi R Helpers, Is it possible to interpret the top level of the list as a date after downloading all the option chain data for a ticker? For example, after I run aapl_total<-getOptionChain("AAPL", NULL) the top descriptor of the lists is a date (Mar.09.2018, Mar.23.2018, etc.). So if want

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Sparks, John
Looks great. Thanks! --JJS From: Dirk Eddelbuettel on behalf of Dirk Eddelbuettel Sent: Sunday, March 4, 2018 9:41 PM To: Sparks, John Cc: Dirk Eddelbuettel; r-help@r-project.org Subject: Re: [R] Interpret List Label as Date from Quantmod getOptionChain On

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Dirk Eddelbuettel
On 5 March 2018 at 03:13, Sparks, John wrote: | library(quantmod) | #in fairness, I did not include this last time and my example was therefore not reproducible. Apologies to Bert and everyone else #for not following the posting guidelines. | aapl_total<-getOptionChain("AAPL", NULL)> | | How c

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Sparks, John
Hi Dirk, Thanks for your note. I understand that expiry dates are the dates that the option expires, so I don't think that I am confused about that (although the upper limits of one's confusion is difficult to accurately estimate). My lack of clarity come from treating those "dates" as act

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Dirk Eddelbuettel
On 5 March 2018 at 02:46, Sparks, John wrote: | I agree that they look like dates, I don't know how to determine if they are actually dates. You know options but you are confused about maturity dates, i.e. expiry? In information in that list (ie along the date dimension) is the expiry; at each

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Sparks, John
Package? Quantmod. In the subject line. I agree that they look like dates, I don't know how to determine if they are actually dates. Josh Ulrich usually answers questions along these lines very informatively and quickly. One reasonable course of action is to wait to see if he does the sa

Re: [R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Bert Gunter
Package? The **names** of the top levels of your lists, "Mar.09.2018", "Mar.23.2018" certainly look like dates and if they are -- I have no idea what package/context is -- they certainly could be formatted as such. See e.g. "date-time" . There are also several package that provide date tools. Che

[R] Interpret List Label as Date from Quantmod getOptionChain

2018-03-04 Thread Sparks, John
Hi R Helpers, Is it possible to interpret the top level of the list as a date after downloading all the option chain data for a ticker? For example, after I run aapl_total<-getOptionChain("AAPL", NULL) the top descriptor of the lists is a date (Mar.09.2018, Mar.23.2018, etc.). So if want

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
On Sun, Mar 4, 2018 at 3:23 PM, Duncan Murdoch wrote: > On 04/03/2018 5:54 PM, Henrik Bengtsson wrote: >> >> The following helps identify when .GlobalEnv$.Random.seed has changed: >> >> rng_tracker <- local({ >>last <- .GlobalEnv$.Random.seed >>function(...) { >> curr <- .GlobalEnv$.R

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
On Sun, Mar 4, 2018 at 10:18 AM, Paul Gilbert wrote: > On Mon, Feb 26, 2018 at 3:25 PM, Gary Black > wrote: > > (Sorry to be a bit slow responding.) > > You have not supplied a complete example, which would be good in this case > because what you are suggesting could be a serious bug in R or a pa

Re: [R] Random Seed Location

2018-03-04 Thread Duncan Murdoch
On 04/03/2018 5:54 PM, Henrik Bengtsson wrote: The following helps identify when .GlobalEnv$.Random.seed has changed: rng_tracker <- local({ last <- .GlobalEnv$.Random.seed function(...) { curr <- .GlobalEnv$.Random.seed if (!identical(curr, last)) { warning(".Random.seed

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
The following helps identify when .GlobalEnv$.Random.seed has changed: rng_tracker <- local({ last <- .GlobalEnv$.Random.seed function(...) { curr <- .GlobalEnv$.Random.seed if (!identical(curr, last)) { warning(".Random.seed changed") last <<- curr } TRUE } }) a

Re: [R] Random Seed Location

2018-03-04 Thread Gary Black
Thank you, everybody, who replied! I appreciate your valuable advise! I will move the location of the set.seed() command to after all packages have been installed and loaded. Best regards, Gary Sent from my iPad > On Mar 4, 2018, at 12:18 PM, Paul Gilbert wrote: > > On Mon, Feb 26, 2018 at

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Bert Gunter
... and note also: > f <- function(...)list(...) <- list(...) ## you cannot have list(...) on LHS > f(x=1,y="a") Error in list(...) <- list(...) : '...' used in an incorrect context In addition to Eric's suggestions, maybe something like this construction is useful: Lapply_me = function(X = X

Re: [R] Random Seed Location

2018-03-04 Thread Paul Gilbert
On Mon, Feb 26, 2018 at 3:25 PM, Gary Black wrote: (Sorry to be a bit slow responding.) You have not supplied a complete example, which would be good in this case because what you are suggesting could be a serious bug in R or a package. Serious journals require reproducibility these days. For

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Thanks Eric, this is working. On Sun, Mar 4, 2018 at 11:28 PM, Eric Berger wrote: > The reason that it works for Apply_MC=TRUE is that in that case you call > mclapply(X,FUN,...) and > the mclapply() function strips off the mc.cores argument from the "..." list > before calling FUN, so FUN is bei

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Eric Berger
The reason that it works for Apply_MC=TRUE is that in that case you call mclapply(X,FUN,...) and the mclapply() function strips off the mc.cores argument from the "..." list before calling FUN, so FUN is being called with zero arguments, exactly as it is declared. A quick workaround is to change t

Re: [R] Random effect in GAM (mgcv)

2018-03-04 Thread David Winsemius
> On Mar 4, 2018, at 7:37 AM, Bert Gunter wrote: > > Statistics questions are largely off topic on this list, although they do > sometimes intersect R programming issues, which are on topic. However, I > believe a statistics list like stats.stackexchange.com might be more > suitable for your qu

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Below is my full implementation (tried to make it simple as for demonstration) Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } r

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Eric Berger
That's fine. The issue is how you called Lapply_me(). What did you pass as the argument to FUN? And if you did not pass anything that how is FUN declared? You have not shown that in your email. On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > My modifie

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
My modified function looks below : Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { myList = list(...)[!names(list(...)) %in% 'mc.cores'] } return(lapply(X, FUN, myList)) } } Here, I a

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Eric Berger
Hi Christofer, Before you made the change that I suggested, your program was stopping at the statement: list(...) = list(..) .etc This means that it never tried to execute the statement: return(lapply(X,FUN,...)) Now that you have made the change, it gets past the first statement and tries to execu

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
@Eric - with this approach I am getting below error : Error in FUN(X[[i]], ...) : unused argument (list()) On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger wrote: > Hi Christofer, > You cannot assign to list(...). You can do the following > > myList <- list(...)[!names(list(...)) %in% 'mc.cores'] >

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Eric Berger
Hi Christofer, You cannot assign to list(...). You can do the following myList <- list(...)[!names(list(...)) %in% 'mc.cores'] HTH, Eric On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso < bogaso.christo...@gmail.com> wrote: > Hi, > > As an example, I want to create below kind of custom Functio

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Hi, As an example, I want to create below kind of custom Function which either be mclapply pr lapply Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) { if (Apply_MC) { return(mclapply(X, FUN, ...)) } else { if (any(names(list(...)) == 'mc.cores')) { list(...) = list(...)[!names(list(

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Duncan Murdoch
On 04/03/2018 10:39 AM, Christofer Bogaso wrote: Hi again, I am looking for some way to alternately use 2 related functions, based on some ifelse() condition. For example, I have 2 functions mclapply() and lapply() However, mclapply() function has one extra parameter 'mc.cores' which lapply do

[R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Hi again, I am looking for some way to alternately use 2 related functions, based on some ifelse() condition. For example, I have 2 functions mclapply() and lapply() However, mclapply() function has one extra parameter 'mc.cores' which lapply doesnt not have. I know when mc.cores = 1, these 2 f

Re: [R] Random effect in GAM (mgcv)

2018-03-04 Thread Bert Gunter
Statistics questions are largely off topic on this list, although they do sometimes intersect R programming issues, which are on topic. However, I believe a statistics list like stats.stackexchange.com might be more suitable for your query. Cheers, Bert Bert Gunter "The trouble with having an

Re: [R] lmrob gives NA coefficients

2018-03-04 Thread Christien Kerbert
d is the number of observed variables (d = 3 in this example). n is the number of observations. 2018-03-04 11:30 GMT+01:00 Eric Berger : > What is 'd'? What is 'n'? > > > On Sun, Mar 4, 2018 at 12:14 PM, Christien Kerbert < > christienkerb...@gmail.com> wrote: > >> Thanks for your reply. >> >> I

[R] Random effect in GAM (mgcv)

2018-03-04 Thread Vaniscotte Amélie
Dear R users, I am using the *mgcv package* to model the ratio of hectares of damaged culture by wild boar in french departments according to some environmental covariates. I used a _Beta distribution_ for the response. For each department, we estimated the damaged in 3 different culture typ

Re: [R] lmrob gives NA coefficients

2018-03-04 Thread Eric Berger
Hard to help you if you don't provide a reproducible example. On Sun, Mar 4, 2018 at 1:05 PM, Christien Kerbert < christienkerb...@gmail.com> wrote: > d is the number of observed variables (d = 3 in this example). n is the > number of observations. > > 2018-03-04 11:30 GMT+01:00 Eric Berger : > >

Re: [R] lmrob gives NA coefficients

2018-03-04 Thread Eric Berger
What is 'd'? What is 'n'? On Sun, Mar 4, 2018 at 12:14 PM, Christien Kerbert < christienkerb...@gmail.com> wrote: > Thanks for your reply. > > I use mvrnorm from the *MASS* package and lmrob from the *robustbase* > package. > > To further explain my data generating process, the idea is as follow

Re: [R] lmrob gives NA coefficients

2018-03-04 Thread Christien Kerbert
Thanks for your reply. I use mvrnorm from the *MASS* package and lmrob from the *robustbase* package. To further explain my data generating process, the idea is as follows. The explanatory variables are generated my a multivariate normal distribution where the covariance matrix of the variables i