Skip to content
Prev 305078 / 398506 Next

use subset to trim data but include last per category

dfthin <- df[ c(which(iter %% 500 == 0),nrow(df) ]

or

 dfthin <- subset(df, (iter %% 500 == 0) | (seq.int(nrow(df)==nrow(df)))

N.B. You should avoid using the name "df" for your variables, because it is the name of a built-in function that you are hiding by doing so. Others may be confused, and eventually you may want to use that function yourself. One solution is to use DF for your variables... another is to use more descriptive names.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Giovanni Azua <bravegag at gmail.com> wrote: