-1

Basically want to input 2 lists and one is a list of total_values = [41,42,40,37,42,..] and the other list is a list of length the sum of the values in total_values, say 700. Call that list set_values. I want the index of each value in total_values and make a new list to return. So I want the new list to contain set_values[41] as the first value. set_values[41+42] as the second value. And set_values[41+42+43] as the third value using the indexed position from total_values. I have try to do this with a nested for loop to increased through the index of total_values but I have no luck and very frustrated... Please let me know if you have any good advice it would be greatly appreciated!!

  • Please make this question *reproducible*. This includes sample code you've attempted (including listing non-base R packages, and any errors/warnings received), sample *unambiguous* data (e.g., `data.frame(x=...,y=...)` or the output from `dput(head(x))`), and intended output given that input. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. (I should add that *describing* data is generally eclipsed by providing actual sample data in an easily-consumed and *unambiguous* format.) – r2evans May 18 '22 at 02:31
  • Why are set values [41+42+43], if your input is [41, 42, 40, ...]? Your goal is not clear. An example of input and desired output, as stated above, and a more detailed explanation of the problem are needed. – user2332849 May 18 '22 at 02:35
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 18 '22 at 09:35

0 Answers0