I am new to R and hence my question is likely to be basic. I tried researching the answer before posting here however didn't get the answer I was looking for.
I am trying to order a data frame on the basis of certain columns. The column is dynamic and depends on a certain "outcome" which would be from a vector of "validoutcomes".
validoutcomes <- c("A","B","C")
if outcome is "A" then I am supposed to read data from column 11. For "B" its columns 17 and for "C" it is 23.
I renamed the columns so that it is easier for my readability and alignment with validoutcomes. "input" is my source data from the CSV.
colnames(input)[11] <- validoutcomes[1]
colnames(input)[17] <- validoutcomes[2]
colnames(input)[23] <- validoutcomes[3]
I then tried to sort using
statelist <- statelist[order(statelist$outcome)]
Any ideas?