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
1 answer

Add ID column to R CoreNLP package tokenizer output using lapply

I have working code to get tokenizer output from CoreNLP using lapply and do.call. I need help to achieve 2 things if possible: Add Document Id in the apply function itself (Currently code doesn't have this column added) Achieve the results of…
amitkb3
  • 303
  • 4
  • 14
0
votes
1 answer

Loop linear regression and saving ALL coefficients

Based on the link below, I created a code to run regression on subsets of my data based on a variable. Loop linear regression and saving coefficients In this example I created a DUMMY (0 or 1) to create the subsets (in reality I have 3000…
research111
  • 347
  • 5
  • 18
0
votes
0 answers

joining a list of data.frames to a single data.frame

I'm not quite smart enough to understand lists, I guess... Say I have a dataframe df thusly: > df <- data.frame(id=1, data=runif(3)) > df id data 1 1 0.9343525 2 1 0.9950256 3 1 0.3557431 and I want to join a list of other data frames…
Christoph Safferling
  • 1,116
  • 11
  • 10
0
votes
3 answers

R: I can't convert all my data.frame columns in factors using do.call

I have the following data.frame called training: event.5 er her2 lymph grade TRUE TRUE FALSE FALSE 3 FALSE FALSE TRUE FALSE 3 ... I would like to convert all columns in factors using: training <- do.call(as.factor,…
Johnathan
  • 1,877
  • 4
  • 23
  • 29
0
votes
0 answers

Assign and do.call using variables in R loops

So I have data sets as lists that are 23 rows by 6 columns that I create in a loop. A given list is called List.X, though the variable for that list name in a given loop is curr.list, which is simply all.possible.Lists[i]. Sorry about the length,…
Alex
  • 971
  • 4
  • 15
  • 28
0
votes
2 answers

How to do calculations in R with multiple data.frames or arrays?

UPDATED - I need to perform calculations using 100+ 2-dimensional tables. I understand the tables can be imported into R as data.frames or arrays. Here is an example that illustrates my problem. For simplification, my many tables are represented by…
LuluPor
  • 165
  • 1
  • 11
0
votes
1 answer

r - run a user defined function several times by taking column elements as parameters

When x[1,1]=net2013 , I get the output as 20. But what do I have to do to execute this piece of code for all the elements of the first column of x (i.e: x[ ,1]). While loop didn't execute and I'm having trouble with apply and do.call. I have to…
0
votes
2 answers

combine data.frame columns to new columns by vector of names

I like to combine some columns of a data.frame to a new column, like dat <- data.frame( color = sample(c("r","y","b"), 10, replace = TRUE), year = sample(2011:2014, 10, replace = TRUE), type = sample(c("early","mid","late"), 10, replace =…
ckluss
  • 1,477
  • 4
  • 21
  • 33
0
votes
1 answer

how to compile function in C code using RcppEigen

I am very new to Rcpp, or more specifically RcppEigen, and struggling with how to use RcppEigen to compile C++ function. Here is the C++ code in which some problems maybe exist. #include #include using namespace Eigen; using…
JunhuiLi
  • 95
  • 13
0
votes
3 answers

rbind multiple dataframes within a function

I found this code line below on SO and it worked as a charm outside a function to identify the list of dataframes and join them using rbind. mylist<-ls(pattern='leg_') mleg <- do.call(rbind, lapply(mylist, get)) But when I enclose this…
speedchase
  • 41
  • 1
  • 7
0
votes
1 answer

tweenjs .call() called to soon

the onComplete Method that is inside of .call is called to soon. It should be called only at the end. code createjs.Tween.get(this).to({filled: 1}, duration).addEventListener("change", () => { this.renderFill(color)}).call(onComplete()); I tried to…
Paul
  • 1,325
  • 2
  • 19
  • 41
0
votes
1 answer

Difference between `do.call()` a function and directly call a function in R?

Here is my code: >ipo_num_year<- do.call(length,list(as.name(paste0("all_data_align_",year)))) >ipo_num_year >90 >ipo_num_year<- length(as.name(paste0("all_data_align_",year))) >ipo_num_year >1 year is an string object "1999"; In previous…
lovelyzlf
  • 107
  • 1
  • 11
0
votes
1 answer

pass function argument down to other function with do.call

I would like to pass object met down to function sf but get object not found error. I think it might have to do with the environment of the top function call that it is not passed to the subfunction: f <- function(fname,x,met=c('sum','subs')){ …
nopeva
  • 1,583
  • 5
  • 22
  • 38
0
votes
1 answer

preserve format when extracting from list in R

I have a for loop that stores in a list one date and one value after some computations. I would like to create a two-column table (date,value) but when I extract the values from the list I can't preserve the date format: n <- 5 x <-…
nopeva
  • 1,583
  • 5
  • 22
  • 38
0
votes
1 answer

Using do.call factor to scale - resetting value error

This is an extension of the question that I asked here: Getting Factor Means into the dataset after calculation Now that I have basically normalized all of the stats that I am interested in using I want to search the data set for people that…
BaseballR
  • 147
  • 2
  • 12
1 2 3
15
16