KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I understand that I can order a data.frame as such: test = data.frame(A=c(4,2,4), B=c(8,3,2)) ordered = test[with( test, order(A,B)) , ] But how do I accomplish the same thing when the columns are specified by column name as character variable? This doesn't seem to work: test = data.frame(A=c(4,2,4), B=c(8,3,2)) cols = c( "A" , "B" ) ordered = test[ with( test, order(cols )) , ] Is there a way to convert "B" to B so that the column is recognized? I seem to have this problem quite often with functions that take column name inputs. Is there some term to describe this problem-space in R (character identifier versus non-character identifier)?
Tags (comma-separated)
Save Edits
Cancel