All Questions
1,072 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 ...
0
votes
2
answers
56
views
Compare elements and their position in two python lists
I have two lists: list_1 and list_2.
list_1 contains integers,
list_2 contains integers + chars (I added it in list_2 by concatenating int, str using the str() func).
list_1 = ['101', '102', and so on....
0
votes
2
answers
94
views
How to keep track of where you are in an Ansible loop?
I need to write some lines in a YAML file for a variable number of times:
- name: Retry a task until a certain condition is met
lineinfile:
path: /root/file
insertafter: '^listeners:'
...
1
vote
1
answer
133
views
Do for loops get slow the longer it iterates? Why are these two for-loop performances different?
I am currently creating a BIG_INTEGER struct of my own in pure C as a pastime project. One of the functions that I decided to implement into my project is a PRNG that returns a random BIG_INTEGER with ...
1
vote
0
answers
62
views
Julia - Reduce allocation in nested for loops
I have a function that calculates the expectation and covariance of random variables on a grid with dimensions (nx, ny, nz). The variables y and z are Markovian, with Qy and Qz being their Markov ...
0
votes
1
answer
31k
views
Iterations and multi-replacement
I have a file named file.in that contains 6 columns of data. One of the columns contains the mean and another contains the error. File.in is around 900 lines long with a different value for mean and ...
1
vote
3
answers
135
views
How to iterate through a dictionary to get values on the lowest level?
Please help me understand how to extract the value of each ingredient for each product and do something with it. But for starters I just want to print them all one by one.
MENU = {
"product_1&...
0
votes
0
answers
66
views
Loop over grouped data in R
I have two dataframes, one where id is a primary identifier and the other is long data. I merged both and so I have long data (this can be reversed). I grouped the data based on id and want to loop ...
-4
votes
1
answer
121
views
C# For loop with try catch finally
I am trying to run for loop for every 5 secs to get the readings from COM port. When successful getting the readings only once. Would like to run the loop even if there is error. sometimes the ...
0
votes
2
answers
41
views
Setting the counter (j) for (inner for loop)
enter image description hereCan anyone tell me why we should set the counter j in the inner for loop to (i+1) not (i=0) (beacause I think setting j to i = 0 will get all elements in the array).
And ...
-1
votes
2
answers
88
views
Going back to an earlier index in list iteration
I have this loop over a list:
MyList = ["test", "test2", "test3", "test4", "test5", "test6", "test7"]
for item in MyList:
...
-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
1
answer
94
views
Using R or tidyverse to adjust proportion in my dataframe to match a known parameter (using prop.table or table or anything else)
I'm working on psychological assessment data that was collected in a non-random sample design. My dataframe is formed of "sex" (male and female) and "level of education"("...
0
votes
0
answers
23
views
How can I use a for loop to strip parens from list elements and print them one at a time? [duplicate]
I have a list from an n_choose_k operation. The list is composed of number combinations that are each surrounded by parentheses.
import itertools
number = 9
k = 3
n = range(1,number)
combos = list(...
2
votes
2
answers
676
views
Erasing nodes of a std::map within a range-based "for" loop
I need to check data of a std::map, and remove some of them.
I'm using a range-based "for" loop, like this:
std::map<int, string> data { { 1, "name1" }, { 2, "name2"...