gistlib
main.r# Sample dataframe df <- data.frame(id = c(1, 2, 3, 4, 5), value = c(20, 10, 30, 15, 25)) # Vector to match vec <- c(2, 5, 3, 1, 4) # Ordering the dataframe by the 'value' column based on the vector order df[match(vec, df$id), ] 248 chars10 lines
# Sample dataframe df <- data.frame(id = c(1, 2, 3, 4, 5), value = c(20, 10, 30, 15, 25)) # Vector to match vec <- c(2, 5, 3, 1, 4) # Ordering the dataframe by the 'value' column based on the vector order df[match(vec, df$id), ]
gistlibby LogSnag