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

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -