search for: morearg

Displaying 20 results from an estimated 58 matches for "morearg".

Did you mean: moreargs
2013 Dec 06
2
Using assign with mapply
I have a data frame whose first colum contains the names of the variables and whose second colum contains the values to assign to them: : kkk <- data.frame(vars=c("var1", "var2", "var3"), vals=c(10, 20, 30), stringsAsFactors=F) If I do : assign(kkk$vars[1], kkk$vals[1]) it works : var1 [1] 10 However, if I try with mapply
2003 Oct 14
3
mapply() gives seg fault
Hello everybody. I've been experimenting with mapply(). Does anyone else have problems with: R> mapply(rep,times=1:4, MoreArgs=42) (I get a seg fault). robin R> R.version _ platform powerpc-apple-darwin6.6 arch powerpc os darwin6.6 system powerpc, darwin6.6 status beta major 1 minor 8.0 year 2003 month 10 day 02 language R >
2005 Nov 20
1
mapply() gives seg fault (PR#8332)
--KsGdsel6WgEHnImy Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, people. Wandering in R archives, and seeing the message attached below, I noticed that: mapply(rep,times=1:4, MoreArgs=42) still segfaults on R 2.2.0, and thought I should be a good citizen and report it, even if I do not have an actual problem with this. :-) > version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status...
2008 Mar 07
3
merging environments
...erve, but _add_ the contents of a data list -- would something like this do it? Is there a less ugly way? x <- 0 y <- 1 z <- 2 f <- function() { x+y+z } f2 <- function(fun,data) { L <- ls(pos=environment(fun)) mapply(assign,names(data),data, MoreArgs=list(envir=environment(fun))) print(ls(pos=environment(fun))) } f2(f,list(a=1)) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 252 bytes Desc: OpenPGP digital signature Url : https://stat.ethz.ch/piper...
2012 Dec 11
1
Rprof causing R to crash
...length(vnames.final.mod) start.time<-Sys.time() for(k in 1:nvars.final){ pred.range<-train.dat[,match(vnames.final.mod[k],names(train.dat))] pred.rng[,k]<-mapply(CalcMESS,tiff.entry=temp[,match(vnames.final.mod[k],names(temp))],MoreArgs=list(pred.vect=pred.range)) } Sys.time()-start.time Rprof("C:\\temp\\mapply.out") for(k in 1:nvars.final){ pred.range<-train.dat[,match(vnames.final.mod[k],names(train.dat))] pred.rng[,k]<-...
2008 Oct 05
1
plyr package: passing further arguments fail
...following example does not work like the standard mapply, library(plyr) df <- data.frame(a=1:10 , b=1:10) foo1 <- function(a, b, cc=0, d=0){ a + b + cc + d } mdply(df, foo1, cc=1) # fine mdply(df, foo1, d=1) # fails mdply(df, foo1, cc=1, d=2) # fails mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(d=1)) mapply(foo1, a=df$a, b=df$b, MoreArgs=list(cc=1, d=2)) Best regards, baptiste
2012 Oct 23
0
Typos/omissions/inconsistencies in man page for clusterApply
...(parLapply) function (cl = NULL, X, fun, ...) NULL > args(snow::parLapply) function (cl, x, fun, ...) NULL Same kind of problem with clusterMap (departing from snow::clusterMap but not fully embracing naming convention used by mapply): > args(mapply) function (FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE) NULL > args(clusterMap) function (cl = NULL, fun, ..., MoreArgs = NULL, RECYCLE = TRUE, SIMPLIFY = FALSE, USE.NAMES = TRUE, .scheduling = c("static", "dynamic")) NULL > args(snow::clusterMap) f...
2011 Sep 02
3
merge some columns
Dear all, I would like to know how to merge columns like: Input file: V1 V2 V3 V4 V5 V6 1 G A G G G G 2 A A G A A G Desired output file: V1 V2 V3 1 G/A G/G G/G 2 A/A G/A A/G So for every 2 consecutive columns merge their content into one. Thanks in advance. [[alternative HTML version deleted]]
2006 May 01
5
Adding elements in an array where I have missing data.
This is a simple question but I cannot seem to find the answer. I have two vectors but with missing data and I want to add them together with the NA's being ignored. Clearly I need to get the NA ignored. na.action? I have done some searching and cannot get na.action to help. This must be a common enough issue that the answer is staring me in the face but I just don't see it. Simple
2006 Jun 29
3
advice on arguments
...ike dotlist = list(...) if (type=="s" && !is.null(dotlist$size)) radius <- dotlist$size and pull "size" out of ... myself (and make a note to that effect in the documentation)? (I guess another general solution to this is to ask for lists of arguments, like MoreArgs in mapply(). Another would be to go back and change spheres3d to make size a synonym for radius ... ) any thoughts? Ben Bolker -- 620B Bartram Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525...
2010 Dec 02
2
Hmisc label function applied to data frame
...)[[1]][inds[,1]] var2 = dimnames(cormat)[[2]][inds[,2]] lbl1 = label(d[,var1]) lbl2 = label(d[,var2]) cor_df = data.frame(Var1=lbl1,Var2=lbl2,Cor=cors) The issue that I run into is when trying to get the labels in lbl1 and lbl2. I get the warning: In mapply(FUN = label, x = x, default = default, MoreArgs = list(self = TRUE), : longer argument not a multiple of length of shorter My usage of label seems ambiguous since the data frame could also a label attached to it, aside from labels attached to variables within the data frame. However, the code above does work, with the warning. Aside from...
2006 Aug 31
2
Wish: keep names in mapply() result
...orking copy) @@ -3,8 +3,16 @@ FUN <- match.fun(FUN) dots <- list(...) + if(!is.null(names(dots[[1]]))) { + isNamed <- TRUE + namesX <- names(dots[[1]]) + } else { + isNamed <- FALSE + } + answer<-.Call("do_mapply", FUN, dots, MoreArgs, environment(), PACKAGE="base") + if(isNamed) names(answer) <- namesX if (USE.NAMES && length(dots) && is.character(dots[[1]]) && is.null(names(answer))) names(answer) <- dots[[1]] @@ -47,4 +55,4 @@ } formals(FU...
2011 Sep 29
1
Looking for internal of a function
Dear all, when I look at the internal of mapply() function, I see a line of code: answer <- .Call("do_mapply", FUN, dots, MoreArgs, environment(), PACKAGE = "base") Can somebody please tell me how to find the source code of 'do_mapply' Thanks, [[alternative HTML version deleted]]
2013 Apr 13
0
help on smoothing volatility surface..
...<- unlist(lapply(symbols, FUN = function(x) regmatches(x=x, regexpr('[0-9]{6}', x) ))) puts$maturity <- as.numeric((as.Date(expiries, "%y%m%d") - Sys.Date())/365) puts$IV <- mapply(GetIV, value = puts$Ask, strike = puts$Strike, maturity = puts$maturity, MoreArgs= list(type='put', underlying= underlying.price, dividendYield=0, riskFreeRate = 0.01, volatility = volforcast), SIMPLIFY=TRUE) puts$delta <- mapply(GetDelta, strike = puts$Strike, volatility = puts$IV,...
2011 Jul 21
0
add label attribute to objects?
...ot; > #fails on df > x <- iris > label(x) Sepal.Length Sepal.Width Petal.Length Petal.Width Species "" "" "" "" "" Warning message: In mapply(FUN = label, x = x, default = default, MoreArgs = list(self = TRUE), : longer argument not a multiple of length of shorter > label(x) <- 'some random comment' > label(x) Sepal.Length Sepal.Width Petal.Length Petal.Width Species "" "" "" ""...
2006 Mar 14
1
R CMD check: problems possibly from mapply?
...at <- function(x, na.levels=NULL, na.show=FALSE) { if (!is.data.frame(x)) x <- as.data.frame(x) names <- colnames(x) if (is.null(names)) names <- paste("x",1:ncol(x),sep="") x <- as.data.frame(mapply(as.factora, x, na.level=na.levels, MoreArgs=list(na.show = na.show), SIMPLIFY=FALSE)) colnames(x) <- names return(x) } ############################################################ Any suggestions are appreciated, as I have no idea where else to look. With kind regards, Ulrike
2010 Nov 15
3
indexing lists
Hi List, I'm trying to work out how to use which(), or another function, to find the top-level index of a list item based on a condition. An example will clarify my question. a <- list(c(1,2),c(3,4)) a [[1]] [1] 1 2 [[2]] [1] 3 4 I want to find the top level index of c(1,2), which should return 1 since; a[[1]] [1] 1 2 I can't seem to work out the syntax. I've tried; which(a
2011 Aug 24
1
setMethods/setGeneric problem when R CMD CHECK'ing a package
...("as.yearmon", signature(x = "SpatialPointsDataFrameListZoo"), as.yearmon.SpatialPointsDataFrameListZoo ) # Filename "as.yearmon.SpatialPointsDataFrameListZoo.R" as.yearmon.SpatialPointsDataFrameListZoo=function(x,...) { newlist=mapply(zoo:::as.yearmon,x at list,MoreArgs=list(...),simplify=FALSE) x at list=newlist return(x) } Thoughts? --j -- Jonathan A. Greenberg, PhD Assistant Project Scientist Center for Spatial Technologies and Remote Sensing (CSTARS) Department of Land, Air and Water Resources University of California, Davis One Shields Avenue Davis, CA...
2011 Jan 10
2
How to save the output of "split" command as series of .csv files
Hello, I am looking for a way to quickly split a data frame containing daily temperature readings into a series of individual data frames, one for each year, in order to save them as individual .csv files which will be named according to Year. I would prefer not to use a series of "subset" commands given that there are a differing number of years for the various location. The data
2011 Feb 25
1
speed up process
...ss the arguments for names() and col= correctly, e.g. for the 2nd loop: lapply(mydata_list, FUN=function(x){foo_reg(dat=x, xvar=ind.xvar, yvar=k, col1=1:3, pos=mypos[1:3], name.dat=names(x)[1:3])}) mapply(FUN=function(x) {foo_reg(dat=x, name.dat=names(x)[1:3])}, mydata_list, col1=1:3, pos=mypos, MoreArgs=list(xvar=ind.xvar, yvar=k)) Thanks in advance for any hints. Ivan #create data (it looks horrible with these datasets but it doesn't matter here) mydata1 <- structure(list(species = structure(1:8, .Label = c("alsen", "gogor", "loalb", "mafas",...