Category "for-loop"

Return Array After For Loop

Having a hard time understanding for loops in arrays. Trying to create a Thank You card creator and these are the steps I'm trying to follow: Create a new, empt

Printing multiplication table using arrays and nested for loops

I am working on an assignment to create a multiplication table using a 2D array. This is what I came up with. 'use strict'; window.addEventListener('load',

Save Data to Array Variable in For Loop

I need to find the earliest & latest dates for certain table entries. A link to a diagram of the table. The premise is that every time an entry has a desire

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