Category "for-loop"

How can I get the output as a scalar value not a vector from this function?

I am writing a function to find the definite integral of any function by using the Midpoint method, the output of this function must be a scalar value, where y(

Is there a more efficient way to calculate the difference in months in R

I have a large data frame in a panel structure (201720 rows; 3 columns) which looks as follows: Name <- c("A", "A", "A", "B", "B", "B") Inception <- c(as

Iterating over a dataframe twice: which is the ideal way?

I am trying to create a dataframe for Sankey chart in Power BI which needs source and destination like this. id Source Destination 1 Starting a next point b 1

MATLAB: How to convert data from an excel file (several sheets) to a matrix?

I try to process data from an excel file from several sheets (~200). Luckily the data is always at the same position in each sheet. I wrote the following code f

R : How loop a function creating named dataframes according to dataframes contained in a list passed in argument?

I made a function that takes a dataframe as argument, and creates two dataframes in output according to a threshold value of one of the columns. These 2 output

My python def's doesnt work as expected when called, why?

I'm a bit stuck because I've already written those functions in Java and they work properly, and then, when "converted" to python, they didn't work as expected.

how can I use if condition inside the loop in r

I defined a function creates 3 random numbers from 1 to 36, and I allowed repetition. I want to test how many times I can get three same numbers in one hand in

Awk if else with conditions

I am trying to make a script (and a loop) to extract matching lines to print them into a new file. There are 2 conditions: 1st is that I need to print the value

Unable to create a for loop to convert multiple varialbe into as.factor

I am trying to write a for loop in r to convert multiple variables with similar character pattern in r to as.factor. Below is the function I wrote, R runs the c

How to remove the selected data from saved data when we click on button in a selected one

In my application I have saved the data when we click on it(we can add the multiple data by entering some data and save the multiple data by clicking the save b

Error: " 'float' object is not subscriptable" whenever I try to print certain values from a list of averafes

I created two variables that give the amount of words in a given context that are both positive and negative respectively within a couple of years. The followin

python 3 how to generate multiple random element in list for loops

I'm doing a coding exercise and it's to build a password generator. I understand I need to utilize the for loop with the list containing the elements but I'm ha

Calculation between vectors in nested for loops

I am struggling with an issue concerned with nested for loops and calculation with conditions. Let's say I have a data frame like this: df = data.frame("a" = c(

Inserting multiple values into a string

I am trying to run this command but need to insert new two variables for every time I run this command. I think the right approach is to loop through a dictiona

Nested loop not iterating through entire list

I'm having a problem with my nested loop. I have a list of titles and a list of keywords, and I want to create a new list containing all of the titles that cont

Changing key name of a dictionary by comparing while keeping key value python

I have a dict with two strings "Candy-one" and "Candy-two" as the key and Capacity as the key pair. I wish to replace the strings "Candy-one" and "Candy-two" wi

Run setTimeout with changing time values

I have an array of objects containing a field duration that specifies the duration that the Object should stay visible. Each Object of array has it's own durati

The while loop inside the Python for loop is repeated only once

This is a part of the code that checks the notice that appears while working using pyautogui and resumes the work when it disappears. Capture the guide and make

How do I iterate over two lists?

I have troubles in using for loops in Python. I wrote this code: x=5 people=['Mary','Joe'] genders=['she','he'] for person in people: print(person) for

my copy array function didn't work. i didn't understand why

This code has to copy one array to another via void copy function. But I don't understand why it doesn't work. #include <stdio.h> void copy(int func_arra