All Questions
22 questions
2
votes
2
answers
80
views
How to write an R function that iterates through a data frame of formulas to fit multiple model variations
I have a list of many combinations of model variables that I'm testing for model fit. I need to figure out how to write an R code that iterates through each one in the model fit. This is what I have ...
-1
votes
1
answer
114
views
Repeating an iterating function N times [closed]
I have an iterative function, f(x) = ax + b, which I want to repeat N times. My steps are as follows
1.) Define the iterative function
2.) Assign a value to each repetition
3.) Stop at the Nth ...
1
vote
0
answers
36
views
Create iteration function to apply to a list of dataframes
I was wondering how to perform a recursive calculation over a list of dataframes? I have previously created a for loop that works but I would now like to convert this into a function that I can then ...
0
votes
1
answer
144
views
How can I find number of iterations from this function in R
Maybe you can help me with this code. I got only 4 values, which are right and needed, but also I need to make a table with all iterations, till I get those right values, but I don't know how to get ...
0
votes
2
answers
86
views
Calculation over multiple columns with similar suffix
The example dataframe looks like this:
d = {'id': [1, 2],'year': [1999, 2020],'cat_up': [0, 15], 'cat_down': [2, 60],'dog_up': [1, 11], 'dog_down': [2, 12],'fish_up': [12, 11], 'fish_down': [22, 12]}
...
0
votes
0
answers
176
views
purrr::Compose or any alternative to reduce the run time for a long nested function in R?
Problem: I have several (10+) custom functions, each defining a step in the workflow. I want to run a nested function of these steps over a large data frame for n (50+) periods iteratively. My ...
1
vote
2
answers
53
views
automate repeating models with different data forloop in R
I need to run a lot of replicates on the same model but cycle different data into it on each iteration.
e.g.
db1 <- mtcars
db2 <- mtcars
db3 <- mtcars
for(i in 1:db) {
# keep model ...
1
vote
2
answers
46
views
Use result for next iterative step in R
I am new to iterative computation R. I want to do a serial computation sucn as that I use a previous result in the next one. The code below shows one attempt of a code to compute serial difference ...
1
vote
1
answer
1k
views
For-loop value being updated
I have been practising C# by creating some code to find the factorial of a number.
The problem I have is how C# uses the for loop, and how it keeps the value in a recursive fashion.
Here is my code (...
1
vote
2
answers
78
views
Counting and storing a number of occurrences of one variable, based on another variable of a dataframe in R
Date HomeTeam AwayTeam FTHG FTAG FTR
<chr> <chr> <chr> <dbl> <dbl> <chr>
1 08/10/2018 Man United Leicester ...
0
votes
2
answers
48
views
Regarding iterating a function in python
I wrote follwing code using Python
import numpy as np
x1=np.array([1,2,3,4])
p1=np.array([.1,.2,.3,.4])
def fun1 (x_vec,p_vec):
x11=np.zeros(len(x_vec))
p11=np.zeros(len(p_vec))
for i ...
1
vote
2
answers
163
views
How to use a vector as argument of a function with multiple parameters in r
I have a function with four parameters, three of which are taken from a given dataframe. I want to be able to use the function with a given dataframe using a vector of numbers as argument for the ...
0
votes
2
answers
158
views
How to iterate through a List function?
I'm running a test program where I make a list of strings and try to find which strings have a certain suffix or prefix.
#include <iostream>
#include <list>
#include <string>
using ...
0
votes
3
answers
153
views
How to iterate over functions?
I would like to apply loop over a function. I have the following "mother" code:
v = 1;
fun = @root;
x0 = [0,0]
options = optimset('MaxFunEvals',100000,'MaxIter', 10000 );
x = fsolve(fun,x0, options)
...
3
votes
2
answers
1k
views
Iterate an array into a custom grid
I have a gird similar with a table with columns and rows but custom created with divs and spans and I want to populate every cell with values from many arrays and is not really working :|
so this is ...