r - What is -c and nrow doing in body of function -


can please explain me what

bdf <- by(bdf, bdf$serial_number, function(sn, k) {                      sn[-c(1:k, (nrow(sn)-k+1):nrow(sn)),]                      }, k = 10) 

is doing? by() splits data frame bdf second argument serial_number , applys function function(sn, k) in third argument. don't understand body of function.

c() creates vector. - makes numbers in vector negative. vector in "row" position of [, omitting rows 1 k, , nrow(sn) - k + 1 end of data frame. it's chopping off first k , last k - 1 rows of data frame.


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -