r - deleting rows from main dataset -
i try keep simple. have dataset 50407 rows , 422 columns. within 50k rows search data points comes 346 rows , 422 columns. id 346 rows. added new column called mode , put in a. after have 346 rows , 423 column. add 347 rows 50407 new column mode.
maindata <- data.frame(main_set) cutdata <- data.frame(cut_set) data_set <- rbind(maindata, cutdata) add_data <- unique(data_set)
when may guess because of new column there unique data not gets cut.
so i'm not sure try now. whatever can give.
example main column0|column1|column2|column3|mode 4 | 83 | 23 | 863 | b 53 | 26 | 9 | 153 | b 33 | 66 | 91 | 693 | b 6 | 87 | 27 | 863 | b 57 | 27 | 9 | 153 | b 37 | 67 | 97 | 693 | b example cut column0|column1|column2|column3|mode 6 | 87 | 27 | 863 | 57 | 27 | 9 | 153 | 37 | 67 | 97 | 693 | rbind column0|column1|column2|column3|mode 4 | 83 | 23 | 863 | b 53 | 26 | 9 | 153 | b 33 | 66 | 91 | 693 | b 6 | 87 | 27 | 863 | b 57 | 27 | 9 | 153 | b 37 | 67 | 97 | 693 | b 6 | 87 | 27 | 863 | 57 | 27 | 9 | 153 | 37 | 67 | 97 | 693 |
idea answer
column0|column1|column2|column3|mode 4 | 83 | 23 | 863 | b 53 | 26 | 9 | 153 | b 33 | 66 | 91 | 693 | b 6 | 87 | 27 | 863 | 57 | 27 | 9 | 153 | 37 | 67 | 97 | 693 |
you use dplyr manipulate data. lets want mark cars in mtcars according number of cylinders , horsepower:
require(dplyr) mtcars %>% group_by(cyl) %>% mutate(mode = ifelse(hp > 180,"a","b")) %>% data.frame()
this way cars grouped cylinder number , tagged "a" if horsepower greater 180 , "b" if hp lower 180.
Comments
Post a Comment