r - Deleting a row from a data set -
I am trying to create a function that rows a code in the n Removes. The rows that I want to delete are the minimum values in the data set from my_data_set column time .
I currently
delete_data < - function (n) {k = 1 while (k & lt; = n) {my_data_set = my_data_set [- (.min (my_data_set $ time)),] k = k + 1}} When I manually input these lines ( while using the loop) it works perfectly, but I'm not able to work the loop.
I am calling the function:
delete_data (n = 2) Any help is appreciated !
Try
Try:
My_data_set [! My_data_set $ time == minutes (my_data_set $ time),] or if you are using data and would like to use more direct syntax providing datatable:
Library (Data Eligible) SetDT (my_data_set) my_data_set [! Time == minutes (time)] Then review how to work R R is a vector of language that can take you through a lot without taking the help of complex loops Makes more sense
Comments
Post a Comment