Loops in R programming,2019 Community Moderator ElectionFinding both count and average of a column in R data.table, after group byROC curves/AUC values as a performance metricTechnical name for this data wrangling process? Multiple columns into multi-factor single columnR Programming rearranging rows and colums from timeline dataConvert from many sub-tables to a single tidy dataframeHow do I add a column to a Pandas dataframe based on other rows and columns in the dataframe?Software for automated database processingHow do I prepare data in which each output row depends on multiple input rows?Equivalence of Tidy Data and Third Normal FormFiltering unique row values in SQL, Advanced

Is there a good way to store credentials outside of a password manager?

Did Dumbledore lie to Harry about how long he had James Potter's invisibility cloak when he was examining it? If so, why?

Where does the Z80 processor start executing from?

Sort a list by elements of another list

Applicability of Single Responsibility Principle

Crossing the line between justified force and brutality

Lay out the Carpet

Increase performance creating Mandelbrot set in python

when is out of tune ok?

Replace character with another only if repeated and not part of a word

How does Loki do this?

Valid Badminton Score?

What can we do to stop prior company from asking us questions?

Anatomically Correct Strange Women In Ponds Distributing Swords

Would a high gravity rocky planet be guaranteed to have an atmosphere?

Large drywall patch supports

Inappropriate reference requests from Journal reviewers

Do sorcerers' Subtle Spells require a skill check to be unseen?

Do the temporary hit points from the Battlerager barbarian's Reckless Abandon stack if I make multiple attacks on my turn?

Purchasing a ticket for someone else in another country?

How does it work when somebody invests in my business?

Pole-zeros of a real-valued causal FIR system

Was Spock the First Vulcan in Starfleet?

Can the discrete variable be a negative number?



Loops in R programming,



2019 Community Moderator ElectionFinding both count and average of a column in R data.table, after group byROC curves/AUC values as a performance metricTechnical name for this data wrangling process? Multiple columns into multi-factor single columnR Programming rearranging rows and colums from timeline dataConvert from many sub-tables to a single tidy dataframeHow do I add a column to a Pandas dataframe based on other rows and columns in the dataframe?Software for automated database processingHow do I prepare data in which each output row depends on multiple input rows?Equivalence of Tidy Data and Third Normal FormFiltering unique row values in SQL, Advanced










0












$begingroup$


I want to update this Remaining column in this table below:
enter image description here



How do I do this in R programming?



I tried



while (n.Remaining>0)



n.remaining <- n.total-n.expense



Desired Output:



enter image description here










share|improve this question











$endgroup$
















    0












    $begingroup$


    I want to update this Remaining column in this table below:
    enter image description here



    How do I do this in R programming?



    I tried



    while (n.Remaining>0)



    n.remaining <- n.total-n.expense



    Desired Output:



    enter image description here










    share|improve this question











    $endgroup$














      0












      0








      0





      $begingroup$


      I want to update this Remaining column in this table below:
      enter image description here



      How do I do this in R programming?



      I tried



      while (n.Remaining>0)



      n.remaining <- n.total-n.expense



      Desired Output:



      enter image description here










      share|improve this question











      $endgroup$




      I want to update this Remaining column in this table below:
      enter image description here



      How do I do this in R programming?



      I tried



      while (n.Remaining>0)



      n.remaining <- n.total-n.expense



      Desired Output:



      enter image description here







      r data-mining dataset data data-cleaning






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 21 at 20:50







      FirstSlack

















      asked Mar 21 at 19:47









      FirstSlackFirstSlack

      1016




      1016




















          2 Answers
          2






          active

          oldest

          votes


















          0












          $begingroup$

          in R you just need to do 10-cumsum(expense). This will give you the Remaining column






          share|improve this answer








          New contributor




          Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          $endgroup$




















            0












            $begingroup$

            More complicated than a cumsum, but for loop could look something like:



            for (j in 3:5)
            n[j,'Remaining'] <- n[j-1,'Remaining'] - n[j,'expense']


            If your answer needs to be strictly positive, think about including a while or if statement.






            share|improve this answer









            $endgroup$












              Your Answer





              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "557"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47757%2floops-in-r-programming%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0












              $begingroup$

              in R you just need to do 10-cumsum(expense). This will give you the Remaining column






              share|improve this answer








              New contributor




              Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              $endgroup$

















                0












                $begingroup$

                in R you just need to do 10-cumsum(expense). This will give you the Remaining column






                share|improve this answer








                New contributor




                Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                $endgroup$















                  0












                  0








                  0





                  $begingroup$

                  in R you just need to do 10-cumsum(expense). This will give you the Remaining column






                  share|improve this answer








                  New contributor




                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  $endgroup$



                  in R you just need to do 10-cumsum(expense). This will give you the Remaining column







                  share|improve this answer








                  New contributor




                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer






                  New contributor




                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Mar 22 at 0:57









                  OnyambuOnyambu

                  1161




                  1161




                  New contributor




                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Onyambu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





















                      0












                      $begingroup$

                      More complicated than a cumsum, but for loop could look something like:



                      for (j in 3:5)
                      n[j,'Remaining'] <- n[j-1,'Remaining'] - n[j,'expense']


                      If your answer needs to be strictly positive, think about including a while or if statement.






                      share|improve this answer









                      $endgroup$

















                        0












                        $begingroup$

                        More complicated than a cumsum, but for loop could look something like:



                        for (j in 3:5)
                        n[j,'Remaining'] <- n[j-1,'Remaining'] - n[j,'expense']


                        If your answer needs to be strictly positive, think about including a while or if statement.






                        share|improve this answer









                        $endgroup$















                          0












                          0








                          0





                          $begingroup$

                          More complicated than a cumsum, but for loop could look something like:



                          for (j in 3:5)
                          n[j,'Remaining'] <- n[j-1,'Remaining'] - n[j,'expense']


                          If your answer needs to be strictly positive, think about including a while or if statement.






                          share|improve this answer









                          $endgroup$



                          More complicated than a cumsum, but for loop could look something like:



                          for (j in 3:5)
                          n[j,'Remaining'] <- n[j-1,'Remaining'] - n[j,'expense']


                          If your answer needs to be strictly positive, think about including a while or if statement.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Mar 22 at 11:30









                          bradSbradS

                          644113




                          644113



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Data Science Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47757%2floops-in-r-programming%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                              Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

                              Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High