do.call Questions

3

Solved

I can use do.call to sum two vectors elementwise: do.call(what="+", args =list(c(0,0,1), c(1,2,3)) >[1] 1 2 4 However, if I'd like to call the same operator with a list of three vecto...
Zorina asked 5/8, 2020 at 11:49

3

I love do.call. I love being able to store function arguments in a list and then splatting them to a given function. For example, I often find myself using this pattern to fit a list of different ...
Whit asked 28/1, 2015 at 17:3

3

Solved

I wrote a wrapper around ftable because I need to compute flat tables with frequency and percentage for many variables. As ftable method for class "formula" uses non-standard evaluation, the wrappe...
Steersman asked 23/4, 2019 at 14:48

1

Solved

I want to be able to pass a named list of models (merMod objects) to anova() and preserve the model names in the output. This is particularly useful in the context of using mclapply() to run a batc...
Singer asked 18/10, 2018 at 7:5

2

Solved

I want to extract the minimum value of each element of several matrix that are stored inside a list. I'm using pmin: do.call(pmin, mylist) The problem is that some elements of those matrix are N...
Unhallowed asked 6/6, 2018 at 22:10

3

Solved

I just read the profile of @David Arenburg, and found a bunch of useful tips for how to develop good R-programming skills/habits, and one especially struck me. I have always thought that the apply ...
Shannon asked 6/6, 2018 at 9:37

3

Solved

The question is very similar to this one . It is for combining a list of data frames into a single longer data frame. However, I want to keep the information from which item of the list the data ca...
Myelitis asked 10/5, 2015 at 11:43

2

Solved

I am aware this question has been asked multiple times, but despite of trying to apply the aforementioned solutions i was not able to solve my little problem: I have saved all my .csv that i...
Coordination asked 2/6, 2017 at 12:47

1

Solved

I am trying to rbind a large list of data frames (outputDfList), which is generated by lapply a complicated function to a large table. You can recreate outputDfList by: df1=data.frame("randomseq_c...
Urbanity asked 16/1, 2017 at 17:21

1

Solved

I want to order a dataset based on an user input. The user input will be a char array (of column name), called cols below. dataset1[do.call('order', as.list(dataset1[cols])),] This works fine. ...
Rivulet asked 12/10, 2016 at 16:55

2

Solved

I want to do.call an (exported) function from a package and need to specify the package and function in the what argument as a character string (i.e., when the package is not loaded into my environ...
Golda asked 16/8, 2016 at 19:41

1

Solved

I want to convert a list to a data frame, with the following code: ls<-list(a=c(1:4),b=c(3:6)) do.call("rbind",ls) The result obtained by adding do.call is as shown below. It returns a data.f...
Multiplication asked 28/1, 2016 at 23:32

5

Solved

I was hoping to be able to construct a do.call formula for subsetting without having to identify the actual range of every dimension in the input array. The problem I'm running into is that I can't...
Immemorial asked 19/7, 2013 at 16:19

1

Solved

Consider a simple function, which adds a ggtitle to a grob f <- function(PLOT, TITLE) { PLOT + ggtitle(TITLE) } Calling the function directly works as expected. However, calling the function...
Poult asked 7/5, 2015 at 17:15

3

Solved

I'm using the following construct in a package, ## two functions in the global environment funa <- function(x) x^2 funb <- function(x) x^3 ## called within a function, fine fun_wrap <- fu...
Mal asked 25/9, 2014 at 0:12

1

Solved

My question is how I might be able to add more arguments to the do.call function. For example, I want to draw faceted grid plots with grid.arrange, how can I add more arguments such as ncol=3 and m...
Elgin asked 21/9, 2014 at 18:44

3

Solved

I have a data frame that is some 35,000 rows, by 7 columns. it looks like this: head(nuc) chr feature start end gene_id pctAT pctGC length 1 1 CDS 67000042 67000051 NM_032291 0.600000 0.40000...
Dent asked 15/6, 2012 at 15:54

2

Solved

I am trying to import and merge a set of csv files using the following code, but it doesn't seem to be passing the by=c("X","Y") argument to the merge function. Any recommendations on how to fix th...
Rundell asked 25/3, 2014 at 19:46

2

Solved

I just ran a series of models in a nice, flexible way that enforced data-code separation. I had a nice list of formulas and models in my configuration section which I lapply'd over to get a list of...
Ezekielezell asked 27/2, 2014 at 21:41

3

Solved

I would like to merge multiple data.frame in R using row.names, doing a full outer join. For this I was hoping to do the following: x = as.data.frame(t(data.frame(a=10, b=13, c=14))) y = as.data.f...
Csch asked 9/2, 2013 at 0:36

3

Solved

This question is a follow-up to a previous answer which raised a puzzle. Reproducible example from the previous answer: Models <- list( lm(runif(10)~rnorm(10)),lm(runif(10)~rnorm(10)),lm(runif...
Uncle asked 7/8, 2013 at 16:13

3

I have a problem when combining the following vectors included in the list: x <- list(as.numeric(c(1,4)),as.numeric(c(3,19,11))) names (x[[1]]) <- c("species.A","species.C") names (x[[2]]) &...
Dixiedixieland asked 5/1, 2012 at 17:8

1

Solved

Consider this do.call(rbind, list(data.table(x=1, b='x'),data.table(x=1, b=NA))) returns x b 1: 1 x 2: 1 NA but do.call(rbind, list(data.table(x=1, b=NA),data.table(x=1, b='x'))) returns ...
Bedroom asked 27/8, 2013 at 20:45

3

Solved

I am getting an error when I try and combine using expression with do.call and plot. x <- 1:10 y <- x^1.5 I can get the plot I want by using only the plot function: plot(y~x,xlab=expre...
Bassoon asked 16/8, 2013 at 19:41

1

Solved

I have a variation on the oh-so-common problem of how to merge things together in R. I have a set of .txt files in a particular folder, and I have written a function that: makes a list of the f...
Detach asked 18/6, 2013 at 14:23

© 2022 - 2024 — McMap. All rights reserved.