Hi, I need to select 15 elements, always considering the highest values (descending order) but obeying the following configuration:
3A - 4B - 0C - 3D or 2A - 5B - 0C - 3D or 3A - 3B - 2C - 2D If I have, for example, 5 A elements as the highest values, I can only choose 3 (first and third choice) or 2 (second choice) elements. how to make this selection? library(dplyr) Var.1 = rep(LETTERS[1:4], 10) Var.2 = sample(1:40, replace=FALSE) data = data.frame(Var.1, Var.2) (data = data[order(data$Var.2, decreasing=TRUE), ]) Elements = data %>% arrange(desc(Var.2)) Thanks, Prof. Dr. Silvano Cesar da Costa Universidade Estadual de Londrina Centro de Ciências Exatas Departamento de EstatÃstica Fone: (43) 3371-4346 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.