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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -