0

I would like to get running totals according to factors (Well_N), that's why I grouped data with

by_wells_sample <- group_by(sampledata, Well_N)

I would like to get running totals as new column in my dataframe, but as a result I get dataframe in the data frame. Any advice/guidance how to do it properly?

See GitHub repo with question details.

Toto
  • 89,455
  • 62
  • 89
  • 125
dainys
  • 187
  • 1
  • 8
  • 1
    You mean you want a cumulative sum? check out `?cumsum`. Since you seem to use `dplyr`: it should be something like: `mutate(by_wells_sample, newcolumnname = cumsum(valuesToSumUp))` – talat Aug 04 '14 at 13:32
  • Thanks for remarks. Actually, some of my listed code in Git repo works. The reason for my failure was that my data was unsorted according to dates. After I applied `sampledata <- sampledata[order(as.Date(monthly$Date_m, format="%Y-%m-%d")),]` everything went well. – dainys Aug 06 '14 at 05:59

0 Answers0