Questions tagged [do.call]

do.call constructs and executes a function call from a name or a function and a list of arguments to be passed to it.

do.call is an R command that takes a list of arguments, executes a function call and then returns the result of the function call. Full documentation here

231 questions
0
votes
0 answers

do.call cannot find function

First of all, sorry that I do not provide a fully reproducible example, but I'm using the devel version of a BioConductor package and the installation is a bit of a pain in the butt. I am trying to use do.call to invoke functions based on a string I…
PejoPhylo
  • 469
  • 2
  • 11
0
votes
2 answers

Selecting rows from a data frame from combinations of lists

I have a dataframe, dat: dat<-data.frame(col1=rep(1:4,3), col2=rep(letters[24:26],4), col3=letters[1:12]) I want to filter dat on two different columns using ONLY the combinations given by the rows in the data frame…
Devraj
  • 84
  • 6
0
votes
1 answer

Extract data from a nested list and return a data.frame

dput(head(z2,10)) structure(list(name = list("Mary"), department = structure(list( name = list("English")), .Names = "name", id = "300"), department = structure(list( name = list("Math")), .Names = "name", id = "301"), department =…
Ching
  • 135
  • 1
  • 9
0
votes
1 answer

Efficiently applying conditions to a matrix

I have an integer matrix: set.seed(1) counts.mat <- matrix(sample(50,29*10,replace=T),nrow=10,ncol=29) colnames(counts.mat) <-…
dan
  • 6,048
  • 10
  • 57
  • 125
0
votes
1 answer

Unused Argument Error in function during a do.call loop in R

funMergeA <- function(x,y = NULL) { if (is.null(y)) { return(x) } else { return(funMerge(x,y,"a")) } } funMerge <- function(x,y,myby="a") { return(merge.data.frame(x,y,by=myby,all=TRUE)) } b <-…
Chapo
  • 2,563
  • 3
  • 30
  • 60
0
votes
1 answer

How to assign column headers to data frames with in a loop in r?

1) I have 48 tar.gz files in a directory "C:/Users/Me/Desktop/JUNETEST/". The files all have the same format with the exception of a number that represents the hour of the day for each file (i.e. voa_20170601-110000.tar.gz as opposed to…
Reric
  • 21
  • 2
0
votes
3 answers

Combining lists with do.call while preserving each entry of the list on a row

Forgive me if this has been asked before... I have multiple lists that I wish to combine as follows A <- list(c("R", "L", "*", "T", "M", "S", "S", "S", "S", "Y"), c("G", "A", "G", "P", "P", "V", "P"), c("E", "G", "R", "E", "Q", "T", "K", "G",…
joeblow
  • 13
  • 6
0
votes
1 answer

do.call based on output of previous sapply(seq_along()) iteration

I have a named list of some algorithm, which may look like this > algorithm $rBinarize $rBinarize$x [1] 40 and may contain an arbitrary number of additional algorithms. Each algorithm carries out an operation on a spatial object (spObj, of class…
0
votes
1 answer

Nested do.call within a foreach %dopar% environment can't find function passed with .export

I am nesting multiple levels of do.call (each themselves using functions named in the parameters, not hard-coded) within a %dopar% parallelized environment, and a function from my outside environment can't be found by the innermost function. I know…
Randall
  • 3
  • 1
0
votes
0 answers

Aggregation using do.call creating multiple rows in R

I have a data frame (date, stock, price, size) for which I want to aggregate the number of instances, sum the size and get min and max of price. That part works, however, the final output contains multiple rows of the same ticker. For example, DGAZ…
mks212
  • 901
  • 1
  • 18
  • 40
0
votes
2 answers

Understanding do.call semantics based on "plot"

I'm fooling around with do.call. I = iris do.call(what = "plot", args = c(I$Sepal.Length ~ I$Sepal.Width)) # This seems fine p = list(x = I$Sepal.Length, y = I$Sepal.Width) do.call(what = "plot", args = p) # This looks weird p1 = list(x =…
New_to_this
  • 135
  • 1
  • 1
  • 8
0
votes
1 answer

do.call BoxCox Error

I'm trying to calculate several BoxCox lambda parameters, for a list of several time-series using the line of code below. I'm getting the error below. I've tried googling the error with no luck, if someone could please point out the issue I'd be…
ndderwerdo
  • 85
  • 8
0
votes
1 answer

`dmap_if` and 'model.matrix' together

I am using Arthritis data set from vcd package to perform one hot encoding. I would like to usepurrr::dmap_if and Matrix::model.matrix together to to do this. When I run do.call(model.matrix, list(Improved~.,Arthritis)) working fine. When I use…
BigDataScientist
  • 1,045
  • 5
  • 17
  • 37
0
votes
1 answer

Merging zoo object using do.call in R

A have several csv file like this : ,timestamp,AirTemperature_House 1,2013-09-01 00:00:00,8.22 2,2013-09-01 01:00:00,6.53 3,2013-09-01 02:00:00,6.67 4,2013-09-01 03:00:00,5.58 5,2013-09-01 04:00:00,4.16 6,2013-09-01…
0
votes
1 answer

R load csv files from folder

I am loading a bunch of csv files simultaneously from a local directory using the following code: myfiles = do.call(rbind, lapply(files, function(x) read.table(x, stringsAsFactors = FALSE, header = F, fill = T, sep=",", quote=NULL))) and getting…
Nir Regev
  • 135
  • 1
  • 2
  • 7