Re: [R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-28 Thread Eric Berger
Hi Anul, Try this (it worked for me) mapply (chart_Series, mget(symVec), name=infoVec, MoreArgs=list(pars=cp, theme=ct )) Best, Eric On Sun, Jul 28, 2019 at 7:03 PM Anuj Goyal wrote: > It compiles without errors, but the chart_pars() and chart_theme() are > not being applied. eg. the Right Y-

Re: [R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-28 Thread Anuj Goyal
It compiles without errors, but the chart_pars() and chart_theme() are not being applied. eg. the Right Y-axis label still exists in p.pdf. Is it possible that cp and ct don't easily vectorize? # R --silent --vanilla < sof.r library(quantmod) options("getSymbols.warning4.0"=FALSE) options("getSymb

Re: [R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-28 Thread Eric Berger
Hi Anuj, I am providing comments regarding your first attempt to call mapply. Since you are working with named arguments, you shouldn't need to include the NULLs in the call. Also you have provided the argument MoreArgs twice, which is what is causing the Error message. You can replace that call wi

[R] mapply, quantmod::chart_Series, MoreArgs error with chart_pars(), chart_theme()

2019-07-27 Thread Anuj Goyal
R version 3.6.0 (2019-04-26) on Mac 10.14.5 What is the proper way to pass chart_pars() as well as chart_theme() into MoreArgs for use in quantmod::chart_Series? p.txt === s,n ABBV,AbbVie BMY,Bristol sof.r === # R --silent --vanilla < sof.r library(quantmod) options("getSymbols.warning4.

Re: [R] MApply and SubStr

2015-02-11 Thread Brian Trautman
That's exactly what I wanted, thank you very much! My intent was to perform the SubStr operation first, and then apply the types to the columns. I wasn't expecting the two types in the same column. I appreciate your response! On Tue, Feb 10, 2015 at 5:03 PM, David Winsemius wrote: > > On Feb 1

Re: [R] MApply and SubStr

2015-02-10 Thread David Winsemius
On Feb 10, 2015, at 3:58 PM, Brian Trautman wrote: > Hi! > > I'm trying to write a custom function that applies SubStr to a string, and > then depending on the arguments, converts the output to a number. > > The substring part of my code works fine, but it's not converting the way I > want to -

[R] MApply and SubStr

2015-02-10 Thread Brian Trautman
Hi! I'm trying to write a custom function that applies SubStr to a string, and then depending on the arguments, converts the output to a number. The substring part of my code works fine, but it's not converting the way I want to -- options('stringsAsFactors'=FALSE) require(data.table) substr_ty

Re: [R] mapply echoes function call when browser() is called from within FUN

2014-04-26 Thread Duncan Murdoch
On 26/04/2014, 11:42 AM, Rguy wrote: When mapply is applied to a function that has a call to browser() within it, the result can be a disastrous amount of feedback. To clarify this situation please consider the following function, containing a call to browser within it: plus = function(a, b) {b

[R] mapply echoes function call when browser() is called from within FUN

2014-04-26 Thread Rguy
When mapply is applied to a function that has a call to browser() within it, the result can be a disastrous amount of feedback. To clarify this situation please consider the following function, containing a call to browser within it: plus = function(a, b) {browser(); a + b} A plain vanilla call

Re: [R] mapply on multiple data frames

2013-06-11 Thread arun
A.K. - Original Message - From: "Webb,Elizabeth E" To: "r-help@R-project.org" Cc: Sent: Tuesday, June 11, 2013 2:07 AM Subject: [R] mapply on multiple data frames Hi all- I am wondering about using the mapply function to multiple data frames.  Specifically, I woul

[R] mapply on multiple data frames

2013-06-10 Thread Webb,Elizabeth E
Hi all- I am wondering about using the mapply function to multiple data frames. Specifically, I would like to do a t-test on a subset of multiple data frames. All data frames have the same structure. Here is my code so far: f<-function(x,y) { test<-t.test(x$col1[x$col3=="num",],v$col2[x$col3=

Re: [R] mapply instead for loop

2012-11-03 Thread Omphalodes Verna
Thanks for help.   But, I am surprised, that mapply is slower than for loop?   OV     From: Uwe Ligges Cc: "r-help@r-project.org" Sent: Saturday, November 3, 2012 4:32 PM Subject: Re: [R] mapply instead for loop On 30.10.2012 20:01, Omphal

Re: [R] mapply instead for loop

2012-11-03 Thread Uwe Ligges
On 30.10.2012 20:01, Omphalodes Verna wrote: Hi all! My question in about using mapply instead for loop. Below is a example with for loop: Is it posible to give same results with mapply function? Thanks for help! OV x <- 1:10 y <- 1:10 xyz <- data.frame(expand.grid(x,y)[1], expand.grid(x,y

[R] mapply instead for loop

2012-10-30 Thread Omphalodes Verna
Hi all!   My question in about using mapply instead for loop. Below is a example with for loop: Is it posible to give same results with mapply function?   Thanks for help!   OV   x <- 1:10 y <- 1:10 xyz <- data.frame(expand.grid(x,y)[1], expand.grid(x,y)[2], z = rnorm(100)) names(xyz) <- c("x", "y

Re: [R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

2012-05-03 Thread Casper Ti. Vector
Thank you very much, though I still don't quite undertdand the explanation :) Nevertheless, I just found a seemingly simple (at least quiker to type) solution after try-and-error: eval(mapply(function(x) {x; function() x}, c("a", "b"))) Wish it may help future readers. On Thu, May 03, 2012 at

Re: [R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

2012-05-03 Thread Jessica Streicher
So, to get back to mapply: eval(mapply(function(x) substitute(function() z,list(z=x)), c("a", "b"))$a)() or like this: mapply(function(x) eval(substitute(function(i) z*i,list(z=x))), c(2,3))[[1]](2) Am 03.05.2012 um 16:02 schrieb Jessica Streicher: > Now.. i just tried around and this might b

Re: [R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

2012-05-03 Thread Jessica Streicher
Now.. i just tried around and this might be a bit strange way to do things.. createFunc<-function(v){ v_out<-NULL for(i in v){ v_out[[i]]<-substitute(function(){x},list(x=i)) } return(v_out) } > y<-createFunc(c("a","b")) > y $a function() { "a"

Re: [R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

2012-05-03 Thread Jessica Streicher
As i see it you will save the actual "text" of the function - and when you call it later on it takes the last value of x it has encountered as the value. I guess you want the x not to be saved as x, but as "a" or "b", so, as its value. I am not sure how to do that however as of yet. Am 03.05.2

[R] `mapply(function(x) function() x, c("a", "b"))$a()' returns `"b"'

2012-05-03 Thread Casper Ti. Vector
As the title says, I want to apply a function (which itself returns a function) to a list (or vector), and get a list (or vector) of generated functions as the return value, but get unexpected result. Anyone with an idea about the reason of this phenomenon and a correct way to implement the requir

Re: [R] mapply & assign to generate functions

2012-03-12 Thread J Toll
ter(10) >  [1] 2.5 > > 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 J Toll >> Sent: Monday, March 12, 2012

Re: [R] mapply & assign to generate functions

2012-03-12 Thread William Dunlap
= 1) > half(10) [1] 5 > third(10) [1] 3.33 > quarter(10) [1] 2.5 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 J Toll > Sent

Re: [R] mapply & assign to generate functions

2012-03-12 Thread Brian Diggs
On 3/12/2012 10:47 AM, J Toll wrote: Hi, I have a problem that I'm finding a bit tricky. I'm trying to use mapply and assign to generate curried functions. For example, if I have the function divide divide<- function(x, y) { x / y } And I want the end result to be functionally equivalent

[R] mapply & assign to generate functions

2012-03-12 Thread J Toll
Hi, I have a problem that I'm finding a bit tricky. I'm trying to use mapply and assign to generate curried functions. For example, if I have the function divide divide <- function(x, y) { x / y } And I want the end result to be functionally equivalent to: half <- function(x) divide(x, 2) th

Re: [R] mapply then export

2011-11-14 Thread R. Michael Weylandt
Perhaps something like: sapply(1:40, function(n) c(gauss.quad(n)$nodes, rep(NA, 40-n))) sapply(1:40, function(n) c(gauss.quad(n)$weights, rep(NA, 40-n))) You'll have to decide how you want the records combined but this should get you going in the right direction Michael PS -- it's polite to say

[R] mapply then export

2011-11-14 Thread RisConfusingMe
To use the gauss.quad function: gauss.quad(n,type) which returns two lists $nodes and $weights whose length will each equal n. I'd like to do this for n=1 to 40 (type will not change) and have a dataset with 40 rows and 81 columns with all the nodes and weights. The first record would have N1 a

Re: [R] mapply to lapply

2011-04-18 Thread Andreas Borg
owInd,3],e=cells[rowInd,5]))) Error in paste("f", i, j, "(a,b,c,d)", sep = "") : argument "i" is missing, with no default What do you think I should try out now? Vielen Dank Alex --- On Mon, 4/18/11, Andreas Borg wrote: From: Andreas Borg Subj

Re: [R] mapply to lapply

2011-04-18 Thread Alaios
Thanks you very much. You made it work! Cheers --- On Mon, 4/18/11, Kenn Konstabel wrote: > From: Kenn Konstabel > Subject: Re: [R] mapply to lapply > To: "Alaios" > Cc: R-help@r-project.org > Date: Monday, April 18, 2011, 1:06 PM > On Mon, Apr 18, 2011 at 2:10 PM,

Re: [R] mapply to lapply

2011-04-18 Thread Kenn Konstabel
ep = "") : >  argument "i" is missing, with no default > > > What do you think I should try out now? > > Vielen Dank > Alex > > --- On Mon, 4/18/11, Andreas Borg wrote: > >> From: Andreas Borg >> Subject: Re: [R] mapply to lapply >> To

Re: [R] mapply to lapply

2011-04-18 Thread Alaios
rgument "i" is missing, with no default What do you think I should try out now? Vielen Dank Alex --- On Mon, 4/18/11, Andreas Borg wrote: > From: Andreas Borg > Subject: Re: [R] mapply to lapply > To: "Alaios" > Cc: R-help@r-project.org > Date: Monday, Apr

Re: [R] mapply to lapply

2011-04-18 Thread Andreas Borg
My solution would be to use an index variable that goes from 1 to the number of rows that are to be processed, along with a helper function which calls Fwithcellvalue with the suitable arguments: F2[i+1,j+1]<-sum(lapply(1:nrow(cells), function(rowInd) Fwithcellvalue(i=i,j=j,a=cells[rowInd,2],b

[R] mapply to lapply

2011-04-18 Thread Alaios
Dear all, I would like to ask your help concerning converting a mapply function to lapply. The reason is that I would like to use mclapply which requires lapply syntax. The command I would like to convert is: F2[i+1,j+1]<-sum(mapply(Fwithcellvalue,i=i,j=j,a=cells[,2],b=cells[,4],c=cells[,1],d=c

Re: [R] mapply question (?)

2011-02-03 Thread Kenn Konstabel
On Thu, Feb 3, 2011 at 1:26 PM, Albert-Jan Roskam wrote: > Hi, > > I have a function myFun which I want to call multiple times, using > different > argument lists. > myFun("v1", "2009", 1) > myFun("v2", "2008", 1) > myFun("q", "2001") > Notice that the third call is different, you have 3 args in

[R] mapply question (?)

2011-02-03 Thread Albert-Jan Roskam
Hi, I have a function myFun which I want to call multiple times, using different argument lists. myFun("v1", "2009", 1) myFun("v2", "2008", 1) myFun("q", "2001") How can I easily do this in R? Should I use mapply? I unsuccessfully tried something like: x <- list(c("v1", "2009", 1), c("v2", "200

Re: [R] mapply

2009-05-31 Thread Dimitris Rizopoulos
well, you do not have to compute the pairwise difference each time; for instance, you could use something like this (untested): out1 <- outer(a, c, "-") out2 <- outer(b, c, "-") u <- v <- 1:5 mat <- matrix(0, length(u), length(u)) for (i in seq_len(u)) { for (j in seq_len(v)) { res1

[R] mapply

2009-05-30 Thread KARAVASILIS GEORGE
Hello, R users. I would like to count the number of triples (r_i, s_j, t_k) with r_i, s_j, t_k distinct and abs((r_i-t_k)-u)=0 and abs((s_j-t_k)-v)=0, where r_i, s_j, t_k are the elements of three vectors a,b,c with different lengths and u,v=1:n. I have solved this problem writing a subroutine

Re: [R] mapply

2008-03-23 Thread Gabor Csardi
On Sun, Mar 23, 2008 at 11:06:05AM -0400, Mark Leeds wrote: > In an earlier post, a person wanted to divide each of the rows of > > rawdata by the row vector sens so he did below but didn't like it and > > asked if there was a better solution. > > > > rawdata <- data.frame(rbind(c(1,2,2), c

[R] mapply

2008-03-23 Thread Mark Leeds
In an earlier post, a person wanted to divide each of the rows of rawdata by the row vector sens so he did below but didn't like it and asked if there was a better solution. rawdata <- data.frame(rbind(c(1,2,2), c(4,5,6))) sens <- c(2,4,6) temp <- t(rawdata)/sens temp <- t(temp) print

Re: [R] mapply, coxph, and model formula

2007-11-08 Thread Thomas Lumley
On Thu, 8 Nov 2007, Erik Iverson wrote: > Hello - > > I am wanting to create some Cox PH models with coxph (in package > survival) using different datasets. > > The code below illustrates my current approach and problem with > completing this. > > ### BEGIN R SAMPLE CODE ##

Re: [R] mapply, coxph, and model formula

2007-11-08 Thread Christos Hatzis
f Of Erik Iverson > Sent: Thursday, November 08, 2007 4:43 PM > To: '[EMAIL PROTECTED]' > Subject: [R] mapply, coxph, and model formula > > Hello - > > I am wanting to create some Cox PH models with coxph (in package > survival) using different datasets. > > T

[R] mapply, coxph, and model formula

2007-11-08 Thread Erik Iverson
Hello - I am wanting to create some Cox PH models with coxph (in package survival) using different datasets. The code below illustrates my current approach and problem with completing this. ### BEGIN R SAMPLE CODE ## library(survival) #Define a function to make tes