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

How to be diplomatic in refusing to write code that breaches the privacy of our users

Class Action - which options I have?

Avoiding estate tax by giving multiple gifts

India just shot down a satellite from the ground. At what altitude range is the resulting debris field?

Was Spock the First Vulcan in Starfleet?

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

Go Pregnant or Go Home

How did Arya survive the stabbing?

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?

How does the UK government determine the size of a mandate?

Return the Closest Prime Number

Why Were Madagascar and New Zealand Discovered So Late?

Efficient way to transport a Stargate

How can a function with a hole (removable discontinuity) equal a function with no hole?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Large drywall patch supports

Why does indent disappear in lists?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Is there a problem with hiding "forgot password" until it's needed?

Unreliable Magic - Is it worth it?

Applicability of Single Responsibility Principle

Is exact Kanji stroke length important?

What does 算不上 mean in 算不上太美好的日子?



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